All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Forney <mforney@mforney.org>
To: linux-kbuild@vger.kernel.org
Subject: [PATCH] kbuild: Add a space after `!` to prevent parsing as file pattern
Date: Wed, 15 Aug 2018 17:13:50 -0700	[thread overview]
Message-ID: <20180816001350.7516-1-mforney@mforney.org> (raw)

Some shells use !(pattern|...|pattern) to match file names not
containing the specified patterns. This may result in output like

  $ ./scripts/clang-version.sh gcc
  ./scripts/clang-version.sh[18]: COPYING: not found
  printf: %d __clang_major__: conversion error
  printf: %d __clang_minor__: conversion error
  printf: %d __clang_patchlevel__: conversion error
  00000
  $

and set CONFIG_CLANG_VERSION to the invalid value '00000'.

POSIX says[0]

  If the pipeline begins with the reserved word ! and command1 is a
  subshell command, the application shall ensure that the ( operator at
  the beginning of command1 is separated from the ! by one or more
  <blank> characters. The behavior of the reserved word ! immediately
  followed by the ( operator is unspecified.

So, just add a <blank> to prevent this.

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_02

Signed-off-by: Michael Forney <mforney@mforney.org>
---
 scripts/clang-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh
index dbf0a31eb111..e65fbc3079d4 100755
--- a/scripts/clang-version.sh
+++ b/scripts/clang-version.sh
@@ -12,7 +12,7 @@
 
 compiler="$*"
 
-if !( $compiler --version | grep -q clang) ; then
+if ! ( $compiler --version | grep -q clang) ; then
 	echo 0
 	exit 1
 fi
-- 
2.17.1

             reply	other threads:[~2018-08-16  3:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16  0:13 Michael Forney [this message]
2018-08-17  1:55 ` [PATCH] kbuild: Add a space after `!` to prevent parsing as file pattern Masahiro Yamada

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=20180816001350.7516-1-mforney@mforney.org \
    --to=mforney@mforney.org \
    --cc=linux-kbuild@vger.kernel.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.