mirror of
https://github.com/Erreur32/cheat.git
synced 2024-10-31 21:11:07 +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
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 New Issue
Block a user