Exit editSub with unset or empty $EDITOR

This commit is contained in:
Adam Goldsmith 2015-11-06 16:25:11 -05:00
parent dad6d54d20
commit 34e6d5fee6
1 changed files with 5 additions and 1 deletions

6
sub.py
View File

@ -39,7 +39,11 @@ def editSub(num):
sub = getSub(getItem(num))
if sub is None:
sys.exit("This item does not have a sub")
editor = os.getenv("EDITOR").split()
editor = os.getenv("EDITOR")
if editor is not None and editor != "":
editor = editor.split()
else:
sys.exit("$EDITOR is unset, cannot edit")
subprocess.call(editor + [os.path.join(os.getenv("TODO_DIR"), sub[0], sub[1])])
def showSub(item, indent=0, color=True):