Skip to main content
15 events
when toggle format what by license comment
Sep 8, 2017 at 12:31 history edited jesse_b CC BY-SA 3.0
added 157 characters in body
Sep 8, 2017 at 12:21 review Suggested edits
Sep 8, 2017 at 12:28
Sep 8, 2017 at 12:21 history edited jesse_b CC BY-SA 3.0
added 77 characters in body
Sep 8, 2017 at 11:56 history edited jesse_b CC BY-SA 3.0
added 443 characters in body
Sep 8, 2017 at 11:29 comment added jesse_b Your variable solution has a similar issue. As soon as you execute the command a second time your returncode variable is overwritten. He also asked to print exit codes not save them. To save them you could do command; echo "command exited with: $?" >> file
Sep 8, 2017 at 11:18 comment added Olivier Dulac I dislike this : this changes the exit code after command ; echo $? because echo $? always succeeds and therefore after it, the new value of $? is now 0. There is a way to keep the original return code even after displaying it, in case this original return code is useful later (For example: in a script, checking the return code is important before deciding how to continue). See my answer for one of several solutions (most of the answers here can be changed in the same way)
Sep 8, 2017 at 10:54 comment added jesse_b I actually like Kusalananda/thrig's answers better. The function is a bit more work upfront but if you want this functionality with more than one command it will save you time in the long run.
Sep 8, 2017 at 8:54 comment added Alexander Mills I am open to persuasion lol
Sep 8, 2017 at 7:56 comment added Kusalananda @AlexanderMills Only you knows which is the most appropriate answer to your question :-)
Sep 8, 2017 at 5:16 comment added Alexander Mills uhhh this seems like it's the best option, so I chose it as the answer, if anyone disagrees, lmk
Sep 8, 2017 at 5:16 vote accept Alexander Mills
Sep 7, 2017 at 20:43 history edited jesse_b CC BY-SA 3.0
added 86 characters in body
Sep 7, 2017 at 20:42 comment added jesse_b I guess it's not. command; echo $? is a much better answer.
Sep 7, 2017 at 20:27 comment added Satō Katsura Err, how's that better than just command; echo $? ?
Sep 7, 2017 at 20:23 history answered jesse_b CC BY-SA 3.0