$?  –  Exit Status

$? is the decimal exit status of the most recent command executed.

Following the execution of a pipe, $? gives the exit status of the last command executed.

Following the execution of a function, $? gives the exit status the last command executed in the function. The return builtin command allows to define the exit status of a function.

Examples

Return from function with exit status 2 and print status
1
2
3
a() { return 2; }
a
echo $?
Output:
1
2
BashSuport Pro ist eine Bash und POSIX IDE mit Unterstützung für $?probieren Sie es aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches