Skip to content

Commit ab0cfad

Browse files
committed
Merge pull request #191 from slackorama/feature/fix-190-exit-error
Feature/fix 190 exit error
2 parents faf3e55 + cd536e2 commit ab0cfad

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/choose.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def getLineObjs():
4949
lineObjs = pickle.load(open(filePath, 'rb'))
5050
except:
5151
output.appendError(LOAD_SELECTION_WARNING)
52+
output.appendExit()
5253
sys.exit(1)
5354
logger.addEvent('total_num_files', len(lineObjs))
5455

@@ -59,7 +60,8 @@ def getLineObjs():
5960
matches = [lineObj for lineObj in lineObjs.values()
6061
if not lineObj.isSimple()]
6162
if not len(matches):
62-
output.writeToFile('echo "No lines matched!!"')
63+
output.writeToFile('echo "No lines matched!!";')
64+
output.appendExit()
6365
sys.exit(0)
6466
return lineObjs
6567

@@ -69,6 +71,7 @@ def setSelectionsFromPickle(selectionPath, lineObjs):
6971
selectedIndices = pickle.load(open(selectionPath, 'rb'))
7072
except:
7173
output.appendError(LOAD_SELECTION_WARNING)
74+
output.appendExit()
7275
sys.exit(1)
7376
for index in selectedIndices:
7477
if index >= len(lineObjs.items()):
@@ -87,7 +90,8 @@ def setSelectionsFromPickle(selectionPath, lineObjs):
8790
filePath = stateFiles.getPickleFilePath()
8891
if not os.path.exists(filePath):
8992
print('Nothing to do!')
90-
output.writeToFile('echo ":D"')
93+
output.writeToFile('echo ":D";')
94+
output.appendExit()
9195
sys.exit(0)
9296
output.clearFile()
9397
# we initialize our args *before* we move into curses

src/output.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def execComposedCommand(command, lineObjs):
4343
appendAliasExpansion()
4444
appendIfInvalid(lineObjs)
4545
appendFriendlyCommand(command)
46+
appendExit()
4647

4748

4849
def editFiles(lineObjs):
@@ -54,6 +55,7 @@ def editFiles(lineObjs):
5455
command = joinEditCommands(partialCommands)
5556
appendIfInvalid(lineObjs)
5657
appendToFile(command)
58+
appendExit()
5759

5860

5961
# Private helpers
@@ -193,6 +195,9 @@ def appendToFile(command):
193195
file.close()
194196
logger.output()
195197

198+
def appendExit():
199+
appendToFile('exit $?;')
200+
196201

197202
def writeToFile(command):
198203
file = open(stateFiles.getScriptOutputFilePath(), 'w')

0 commit comments

Comments
 (0)