|
From: | Eric Blake |
Subject: | Re: [Help-bash] Undocumented caret logical operator? |
Date: | Wed, 2 May 2018 13:58:01 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 05/02/2018 01:06 PM, Greg Wooledge wrote:
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 FALSEOutside 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.
And for more historical trivia, the reason POSIX standardized: case a in [!b]) echo yes;; esac and NOT case a in [^b]) echo yes;; esac(although the latter is permitted as an extension, and bash implements that extension), is BECAUSE of the legacy shells where ^ was an operator and had to be quoted, such that quoting made it harder to use in negated group globs (when compared to the usual spelling of negated groups in regular expressions), while ! did not need quoting.
On a distant tangent, Microsoft's cmd still uses ^-newline as a line continuation escape (although cmd and sh are so radically different that it's unusual to even attempt to write a file that would perform in a sane manner under both shells).
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |