From 72b7af171d2bcf9ae2be889eb011fdb621972a85 Mon Sep 17 00:00:00 2001 From: 0rax Date: Fri, 20 Sep 2013 02:12:48 +0200 Subject: [PATCH] Split EDITOR variable to prevent error on popen while using EDITOR var with spaces --- cheat | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cheat b/cheat index de2d63b..e8de382 100755 --- a/cheat +++ b/cheat @@ -109,11 +109,11 @@ class CheatSheets(object): print('In order to use "create" or "edit" you must set your ' 'EDITOR environment variable to your favorite editor\'s path') exit() - + else: + editor = os.environ['EDITOR'].split() # if the cheatsheet already exists, open it for editing if cheat in sheets.sheets: - subprocess.call([os.environ['EDITOR'], - os.path.join(self.sheets[cheat], cheat)]) + subprocess.call(editor + [os.path.join(self.sheets[cheat], cheat)]) # otherwise, create it else: @@ -121,14 +121,12 @@ class CheatSheets(object): # Attempt to write the new cheatsheet to the user's ~/.cheat dir if it # exists. If it does not exist, attempt to create it. if os.access(DEFAULT_CHEAT_DIR, os.W_OK) or os.makedirs(DEFAULT_CHEAT_DIR): - subprocess.call([os.environ['EDITOR'], - os.path.join(DEFAULT_CHEAT_DIR, cheat)]) + subprocess.call(editor + [os.path.join(DEFAULT_CHEAT_DIR, cheat)]) # If the directory cannot be created, write to the python package # directory, though that will likely require the use of sudo else: - subprocess.call([os.environ['EDITOR'], - os.path.join(cs.cheat_dir, cheat)]) + subprocess.call(editor + [os.path.join(cs.cheat_dir, cheat)]) def list(self): """Lists the cheatsheets that are currently available"""