Timeline for Unix command that immediately returns a particular return code?
Current License: CC BY-SA 3.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 11, 2016 at 12:45 | comment | added | Florian Castellane | related: (non portable) smallest program to return a compile-time fixed value: muppetlabs.com/~breadbox/software/tiny/teensy.html | |
| Oct 10, 2016 at 22:39 | comment | added | webb |
or `exit 56`.
|
|
| Oct 10, 2016 at 16:26 | history | edited | Jeff Schaller♦ |
edited tags
|
|
| Oct 10, 2016 at 16:19 | comment | added | gardenhead |
Well, you have the true and false built-ins if you need to return 0 or 1.
|
|
| Oct 10, 2016 at 15:59 | answer | added | ThePiercingPrince | timeline score: 3 | |
| Oct 10, 2016 at 15:45 | answer | added | Mihir | timeline score: 0 | |
| Oct 10, 2016 at 14:44 | comment | added | Michaël Le Barbier | Just for the record, here is the dual question | |
| Oct 10, 2016 at 12:53 | history | tweeted | twitter.com/StackUnix/status/785463281150529537 | ||
| Oct 10, 2016 at 12:02 | answer | added | Stéphane Chazelas | timeline score: 14 | |
| Oct 10, 2016 at 11:32 | answer | added | tmh | timeline score: 18 | |
| Oct 10, 2016 at 10:31 | comment | added | Olivier Dulac |
if you need this for job control, for example, you can usually change any command into { any command ; exit 56 ; } (or return 56, if you don't want to exit the engobing shell)
|
|
| Oct 10, 2016 at 10:21 | comment | added | Olivier Dulac | This really sounds like a XYProblem : what is the ultimate goal of this? Why do you need a command that returns as exit code the number you give it? | |
| Oct 10, 2016 at 8:14 | comment | added | Bakuriu |
$python -c 'import sys;sys.exit(int(sys.argv[1]))' 56; $echo $? -> 56 works.
|
|
| Oct 10, 2016 at 5:19 | comment | added | cuonglm |
How about (exit 56)?
|
|
| Oct 10, 2016 at 5:03 | comment | added | Chris |
@TimKennedy seems to have guessed what my poorly spec-ed out question was trying to ask and answered it. bash -c 'exit 56' does what I'd like to do!
|
|
| Oct 10, 2016 at 5:00 | history | edited | Chris | CC BY-SA 3.0 |
added 393 characters in body
|
| Oct 10, 2016 at 4:08 | history | edited | muru | CC BY-SA 3.0 |
added 5 characters in body
|
| Oct 10, 2016 at 3:43 | answer | added | agc | timeline score: 47 | |
| Oct 10, 2016 at 3:25 | comment | added | Tim Kennedy |
exit is the only one I can think of, but it tends to end your shell. bash -c 'exit 56' or bash -c "exit $1" might work for you.
|
|
| Oct 10, 2016 at 2:51 | history | asked | Chris | CC BY-SA 3.0 |