Como dijo Thomas Dickey, cualquier shell POSIX (es decir, casi todos) tendrá $?.
Esta pregunta me interesó bastante, así que la probé en cualquier shell que pudiera tener en mis manos:
mksh
zsh
/bin/sh en mi Samsung Galaxy S5
/bin/sh en mi enrutador
tcsh
ksh
dash
/bin/sh en mi sistema virtual UNIX V desde 1989 más o menos
cmd.exey powershell.exeen mi computadora con Windows 10
y $?trabajado en todos estos pero fishy cmd.exe.
Encontramos dos cosas interesantes:
1. $?funciona en Windows PowerShell!
Bueno, hasta cierto punto. En lugar de devolver 0 o un número mayor, es justo Truey False.
PS C:\WINDOWS\system32> echo $?
True
PS C:\WINDOWS\system32> gfdhgfhfdgfdg
gfdhgfhfdgfdg : The term 'gfdhgfhfdgfdg' is not recognized as the name of a cmdlet, ...(big long error output).....
PS C:\WINDOWS\system32> echo $?
False
2. $?no funciona en el shell fish.
Sin embargo, cuando escribe $?pescado, recibe este mensaje:
~$ echo $?
$? is not the exit status. In fish, please use $status.
fish: echo $?
No lo he usado mucho, pero no me sorprende, fishparece tener su propio lenguaje de shell interesante, completamente diferente basho lo que sea.