help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Undocumented caret logical operator?


From: Greg Wooledge
Subject: Re: [Help-bash] Undocumented caret logical operator?
Date: Wed, 2 May 2018 14:06:11 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, May 02, 2018 at 01:51:42PM -0400, G. Branden Robinson wrote:
> The experiments show that it is not acting as an
> "undocumented synonym for |" (bashref re: SVR4.2's Bourne shell)

> echo -n expect TRUE:
> true ^ false && echo TRUE || echo FALSE

Outside of legacy Bourne shells, the ^ is just a character with no
special meaning, like x or % or 8.  Here (above), you're passing two
extra arguments to the "true" command, which simply ignores them.

Here (below), you're passing two extra arguments to "false", which
also ignores them.

> echo -n expect FALSE:
> false ^ true && echo TRUE || echo FALSE

> echo -n expect FALSE:
> false ^ false && echo TRUE || echo FALSE

It's also a really bad idea to chain && and || in the same command
like this.  It is NOT a synonym for "if ... then ... else ... fi",
as I explain at <https://mywiki.wooledge.org/BashPitfalls#pf22>.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]