Skip to main content
24 of 29
deleted 32 characters in body
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Bash 4.2 + extras, 23 exit codes

grep \#$1$ $0|sh;exit man #1 grep #2 curl / #3 sed #4 curl _ #6 curl 0 #7 man / #16 curl -f to/! #22 curl to -o/ #23 curl -L3 x.org #35 curl --capath / -L x.org #60 curl --max-filesize 1 to #63 curl --cacert / -L x.org #77 timeout 1e-9 w #124 / #126 - #127 tcc -run -<<<main=6\; #132 tcc -run -<<<main=204\; #133 $[2**63%-1] #136 {0..1000000000} #137 tcc -run -<<<main=\; #139 exit _ #255 

Thanks to @Ken Y-N for 3 exit codes.

The last one's borderline, but since exit underscore fails because of its non-numeric argument, I think it should count.

I will golf this later.

Verification

$ for n in {0..255}; do bash exit.sh $n ; (($? == $n)) && echo $n >&0; done &> /dev/null 0 1 2 3 4 6 7 16 22 23 35 60 63 77 124 126 127 132 133 136 137 139 255 
Dennis
  • 211.7k
  • 41
  • 380
  • 830