mirror of
https://github.com/cheat/cheat.git
synced 2024-11-16 08:58:28 +01:00
Split EDITOR variable to prevent error on popen while using EDITOR var with spaces
This commit is contained in:
parent
42642526f8
commit
72b7af171d
1 changed files with 5 additions and 7 deletions
12
cheat
12
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"""
|
||||
|
|
Loading…
Reference in a new issue