All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rong Chen <rong.a.chen@intel.com>,
	kernel test robot <lkp@intel.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	kbuild-all@lists.01.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [kbuild-all] Re: [PATCH] gcov: fail build on gcov_info size mismatch
Date: Tue, 16 Mar 2021 10:09:51 +1100	[thread overview]
Message-ID: <20210315230951.GA17229@gondor.apana.org.au> (raw)
In-Reply-To: <CAHk-=wj6OiV_sSZbqz-ZPnL7=NboN-3VQYM6brVCfq2px0EAqg@mail.gmail.com>

On Mon, Mar 15, 2021 at 01:57:58PM -0700, Linus Torvalds wrote:
>
>     $ [ "!"  = ".size" -a "b" = ".LPBX0," ]
> 
> causes
> 
>     dash: 6: [: =: unexpected operator
> 
> because for some reason that "-a" ends up (wild handwaving here about
> what is going on) re-parsing the first expression, and ignoring the
> quoting around "!" when it does so.

The quoting on "!" doesn't help I'm afraid.  Even though [ is a
built-in it is not allowed to look at the quoting because it's
supposed to behave in the same way whether you get the builtin [
or the one from /usr/bin.

So when it gets the expression the quoting on the "!" has already
been removed.

IOW this expression is ambiguous and may or may not fail depending
on how it's parsed.

Note that when you have a simple expression like

	[ "!" = ".size" ]

special rules come into play on how it is parsed:

https://pubs.opengroup.org/onlinepubs/009604499/utilities/test.html

But this does not apply when you construct more complex ones with
-a.

There are two ways around this when writing scripts, you either
add something to ensure that "!" cannot occur, e.g.,

	[ "X$a" = "X$b" -a ... ]

or you break it down into a simpler expression that is guaranteed
by POSIX:

	[ "$a" = "$b" ] && [ ... ]

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

WARNING: multiple messages have this Message-ID (diff)
From: Herbert Xu <herbert@gondor.apana.org.au>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH] gcov: fail build on gcov_info size mismatch
Date: Tue, 16 Mar 2021 10:09:51 +1100	[thread overview]
Message-ID: <20210315230951.GA17229@gondor.apana.org.au> (raw)
In-Reply-To: <CAHk-=wj6OiV_sSZbqz-ZPnL7=NboN-3VQYM6brVCfq2px0EAqg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

On Mon, Mar 15, 2021 at 01:57:58PM -0700, Linus Torvalds wrote:
>
>     $ [ "!"  = ".size" -a "b" = ".LPBX0," ]
> 
> causes
> 
>     dash: 6: [: =: unexpected operator
> 
> because for some reason that "-a" ends up (wild handwaving here about
> what is going on) re-parsing the first expression, and ignoring the
> quoting around "!" when it does so.

The quoting on "!" doesn't help I'm afraid.  Even though [ is a
built-in it is not allowed to look at the quoting because it's
supposed to behave in the same way whether you get the builtin [
or the one from /usr/bin.

So when it gets the expression the quoting on the "!" has already
been removed.

IOW this expression is ambiguous and may or may not fail depending
on how it's parsed.

Note that when you have a simple expression like

	[ "!" = ".size" ]

special rules come into play on how it is parsed:

https://pubs.opengroup.org/onlinepubs/009604499/utilities/test.html

But this does not apply when you construct more complex ones with
-a.

There are two ways around this when writing scripts, you either
add something to ensure that "!" cannot occur, e.g.,

	[ "X$a" = "X$b" -a ... ]

or you break it down into a simpler expression that is guaranteed
by POSIX:

	[ "$a" = "$b" ] && [ ... ]

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2021-03-15 23:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 13:03 [PATCH] gcov: fail build on gcov_info size mismatch Peter Oberparleiter
2021-03-11 18:38 ` Linus Torvalds
2021-03-12 17:46   ` Peter Oberparleiter
2021-03-11 19:33 ` kernel test robot
2021-03-11 19:33   ` kernel test robot
2021-03-11 20:02   ` Linus Torvalds
2021-03-11 20:02     ` Linus Torvalds
2021-03-12  3:49     ` [kbuild-all] " Rong Chen
2021-03-12  3:49       ` Rong Chen
2021-03-12 17:52       ` [kbuild-all] " Linus Torvalds
2021-03-12 17:52         ` Linus Torvalds
2021-03-15  2:31         ` [kbuild-all] " Rong Chen
2021-03-15  2:31           ` Rong Chen
2021-03-15 19:12           ` [kbuild-all] " Linus Torvalds
2021-03-15 19:12             ` Linus Torvalds
2021-03-15 20:32             ` [kbuild-all] " Jamie Heilman
2021-03-15 20:32               ` Jamie Heilman
2021-03-15 20:57               ` [kbuild-all] " Linus Torvalds
2021-03-15 20:57                 ` Linus Torvalds
2021-03-15 23:09                 ` Herbert Xu [this message]
2021-03-15 23:09                   ` Herbert Xu
2021-03-15 23:22                   ` [kbuild-all] " Linus Torvalds
2021-03-15 23:22                     ` Linus Torvalds
2021-03-16  9:51         ` [kbuild-all] " Herbert Xu
2021-03-16  9:51           ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315230951.GA17229@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oberpar@linux.ibm.com \
    --cc=rong.a.chen@intel.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.