Skip to main content
10 events
when toggle format what by license comment
Jan 27, 2023 at 21:51 comment added Stéphane Chazelas @Andrew15_5, [ $? -ne 0 ] in another language would be written equal(glob(split($?)), 0) which makes no sense. [ "$?" -ne 0 ] would be equal($?, 0) which makes sense. See also Security implications of forgetting to quote a variable in bash/POSIX shells
Jan 27, 2023 at 19:57 comment added Andrew15_5 It doesn't complain because $? stores the exit code of a previous command, which implies that $? is a number and doesn't have spaces or newlines (I don't know who would assign a digit to IFS). Hence, it's safe to use it without quotes. And [ <> -ne 0 ] is a perfectly valid command which is another form of test <> -ne 0 (it returns 0 if the expression is true and 1 if false).
Jan 27, 2023 at 17:11 history edited Stéphane Chazelas CC BY-SA 4.0
deleted 2 characters in body
Jan 27, 2023 at 15:58 history edited Stéphane Chazelas CC BY-SA 4.0
added 358 characters in body
Jan 27, 2023 at 15:54 comment added Stéphane Chazelas @Andrew15_5, ShellCheck should complain about the missing quotes in there which make it subject to $IFS-splitting. Or write it last_block_failed() [[ $? -ne 0 ]] or last_block_failed() (( $? != 0 )) Or last_block_failed() (( ! $? ))
Jan 27, 2023 at 15:18 vote accept Andrew15_5
Jan 27, 2023 at 15:17 comment added Andrew15_5 Since this is just [ $? -ne 0 ] in disguise, I will stick with a simplified version: last_block_failed() { [ $? -ne 0 ];}. ShellCheck doesn't complain this way. Thanks for the solution (it also improves readability even further).
S Jan 27, 2023 at 14:36 history suggested Andrew15_5 CC BY-SA 4.0
Added code syntax highlighting
Jan 27, 2023 at 10:08 review Suggested edits
S Jan 27, 2023 at 14:36
Jan 27, 2023 at 7:29 history answered Stéphane Chazelas CC BY-SA 4.0