Skip to main content
9 events
when toggle format what by license comment
Jan 29, 2020 at 13:33 comment added boweeb @toolforger -- yup... that's what I said above. I'm not confused about the math. I'm confused why a developer would want to use a convoluted way to get to 255. My best guess is the convention implies the 255 return code isn't meant to be meaningful (and writing it as -1 is marginally easier to write(?)). RC 1 is common for a generic/unspecified error but I've never seen anything actually eval $? for 255 (specifically).
Jul 3, 2019 at 5:30 comment added toolforger @boweeb -1 mod X == X-1 is pretty normal, you essentially continue the 0,1,...,X-1 sequence into negatives. See en.wikipedia.org/wiki/Modulo_operation for variations and rationale.
Dec 6, 2018 at 18:35 history edited Dennis Williamson CC BY-SA 4.0
additional information
Mar 21, 2018 at 14:00 comment added boweeb Note that you can use the range 0-255 but what actually happens is a modulo against 256. That means you can exit 300 and $? will be 44. Also, exit -1 would return 255 (a strange habit I've seen a lot). Just something to be aware of. It's best to just return the value you desire so stick to 0-255 so you (or someone else) won't get surprised.
May 23, 2017 at 12:32 history edited URL Rewriter Bot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Jul 7, 2016 at 15:50 history edited Dennis Williamson CC BY-SA 3.0
additional information
Jul 14, 2015 at 4:40 comment added Dennis Williamson @ElliotChance: The dollar sign in my answer represents the prompt and works as-is. What you propose would also work, but isn't necessary.
Jul 14, 2015 at 4:35 comment added Elliot Chance Should be $(exit 42); echo "$?"
May 5, 2012 at 0:58 history answered Dennis Williamson CC BY-SA 3.0