Skip to content

Commit

Permalink
Merge pull request #191 from slackorama/feature/fix-190-exit-error
Browse files Browse the repository at this point in the history
Feature/fix 190 exit error
  • Loading branch information
pcottle committed Sep 29, 2015
2 parents faf3e55 + cd536e2 commit ab0cfad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/choose.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def getLineObjs():
lineObjs = pickle.load(open(filePath, 'rb'))
except:
output.appendError(LOAD_SELECTION_WARNING)
output.appendExit()
sys.exit(1)
logger.addEvent('total_num_files', len(lineObjs))

Expand All @@ -59,7 +60,8 @@ def getLineObjs():
matches = [lineObj for lineObj in lineObjs.values()
if not lineObj.isSimple()]
if not len(matches):
output.writeToFile('echo "No lines matched!!"')
output.writeToFile('echo "No lines matched!!";')
output.appendExit()
sys.exit(0)
return lineObjs

Expand All @@ -69,6 +71,7 @@ def setSelectionsFromPickle(selectionPath, lineObjs):
selectedIndices = pickle.load(open(selectionPath, 'rb'))
except:
output.appendError(LOAD_SELECTION_WARNING)
output.appendExit()
sys.exit(1)
for index in selectedIndices:
if index >= len(lineObjs.items()):
Expand All @@ -87,7 +90,8 @@ def setSelectionsFromPickle(selectionPath, lineObjs):
filePath = stateFiles.getPickleFilePath()
if not os.path.exists(filePath):
print('Nothing to do!')
output.writeToFile('echo ":D"')
output.writeToFile('echo ":D";')
output.appendExit()
sys.exit(0)
output.clearFile()
# we initialize our args *before* we move into curses
Expand Down
5 changes: 5 additions & 0 deletions src/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def execComposedCommand(command, lineObjs):
appendAliasExpansion()
appendIfInvalid(lineObjs)
appendFriendlyCommand(command)
appendExit()


def editFiles(lineObjs):
Expand All @@ -54,6 +55,7 @@ def editFiles(lineObjs):
command = joinEditCommands(partialCommands)
appendIfInvalid(lineObjs)
appendToFile(command)
appendExit()


# Private helpers
Expand Down Expand Up @@ -193,6 +195,9 @@ def appendToFile(command):
file.close()
logger.output()

def appendExit():
appendToFile('exit $?;')


def writeToFile(command):
file = open(stateFiles.getScriptOutputFilePath(), 'w')
Expand Down

0 comments on commit ab0cfad

Please sign in to comment.