TR-42 / minishell

https://tr-42.github.io/minishell/
0 stars 0 forks source link

expand exit status #50

Closed TetsuOtter closed 1 year ago

TetsuOtter commented 1 year ago

$?でexit statusの展開を行えるようにしました

minishell> echo $?
0
minishell> grep
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]
minishell> echo $?
2
minishell> bash -c 'exit 3'
minishell> echo $?
3
minishell> bash -c 'exit 3' || echo $?
3
minishell> bash -c 'exit 1' || echo $?
1
minishell> bash -c 'exit 255' || echo $?
255
minishell> bash -c 'exit 256' || echo $?
minishell> bash -c 'exit 257' || echo $?
1
minishell> bash -c 'exit 257' |grep || echo $?
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]
2
minishell>