On Mon, May 27, 2024 at 07:17:37PM +0300, Andy Shevchenko wrote: > On Mon, May 27, 2024 at 08:44:20PM +0800, Kent Gibson wrote: > > On Mon, May 27, 2024 at 02:02:34PM +0200, Bartosz Golaszewski wrote: > > ... > > > > assert_fail() { > > > - $* || return 0 > > > - fail " '$*': command did not fail as expected" > > > + "$@" || return 0 > > > + fail " '$@': command did not fail as expected" > > > } > > > > Ironically, shellcheck doesn't like the '$@' in the fail string[1], so you > > should use $* there. > > But why does it do like this? > Read the link[1]. Because $@ is an array being used to build a string, and that may not work the way you expect. In this case $* is clearer as that has already been concatenated. Cheers, Kent. [1] https://www.shellcheck.net/wiki/SC2145