[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash true/false builtings undocumented? "false" not working?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Aug 17, 2018 at 07:32:39PM +1000, Zenaan Harkness wrote:

[...]

> That accords with my previous understanding, that the exist status of
> running false gives something other than "success" (i.e. zero) - what
> am I missing?

The next step: "$?" expands to "0" in your

  test $? && ...

then "test" sees "0" and thinks "ah, not null (i.e. ""), ergo true",
because the only one-argument call of 'test' which 'fails' would be
test "").

I think to really grok that you need to (re-)make yourself aware of
the shell's evaluation model: first, all the expansions (variable,
path, whatever), then what appears (after expansion) att command
position gets fed what appears in arg position.

Few surviving languages have that kind of evaluation model (the shells,
Tcl -- and in a very interesting twist the Lisps). Powerful, but
sometimes confusing.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlt2mKAACgkQBcgs9XrR2kabGgCdGJt91a3/7a1O6/ugYqVhaQG+
CzcAnjy86+FXlIXJwUh4SU/OLUdLcBeh
=EXEw
-----END PGP SIGNATURE-----


Reply to: