public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Clement Chauplannaz <chauplac@gmail.com>
Cc: linux-kbuild@vger.kernel.org, mmarek@suse.cz, ak@linux.intel.com
Subject: Re: [PATCH] scripts/config: use sed's POSIX interface
Date: Wed, 10 Jul 2013 22:38:29 +0200	[thread overview]
Message-ID: <20130710203829.GD3297@free.fr> (raw)
In-Reply-To: <1373486288-715-1-git-send-email-chauplac@gmail.com>

Clément, All,

On 2013-07-10 21:58 +0200, Clement Chauplannaz spake thusly:
> Script `config' relies on extensions of `GNU sed', and is thus not
> working on all Unixes:
> - in-place edition of files (-i), which can be replaced with
> a temporary file;
> - extended-regexps (-r), which can be split into basic regexps;
> - single-line calls to `a' command, while some implementations
> require a leading newline before the parameter.
> 
> Rewrite calls to `sed' program to comply with POSIX interface.

Clément, sorry I did not come back to you earlier after your second PM.
Here is further review:

> Signed-off-by: Clement Chauplannaz <chauplac@gmail.com>
> ---
>  scripts/config | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/config b/scripts/config
> index a65ecbb..3fd95eb 100755
> --- a/scripts/config
> +++ b/scripts/config
> @@ -66,9 +66,14 @@ set_var() {
>  	name_re="^($name=|# $name is not set)"
>  	before_re="^($before=|# $before is not set)"
>  	if test -n "$before" && grep -Eq "$before_re" "$FN"; then
> -		sed -ri "/$before_re/a $new" "$FN"
> +		lf=$'\n'

As you explained me earlier, you expect this to actually set the '\n'
symbol (0x0a) as first char of variable 'lf'. This is a bashism, and is
not POSIX. Here is a test script:

    #!/bin/dash
    lf=$'\n'
    printf "lf='%s'\n" "${lf}"
    printf "lf='${lf}'\n"

And the output:
    lf='$\n'
    lf='$
    '

Now, if you use #!/bin/bash, it works as you expect, but not with a
POSIX-only script like dash.

A reliable way to get a single '\n' would be:

    lf="$( printf '\n' )"

Yes, config is already a bash script, but no need to add bashisms when
they can be avoided. And since this patch is about POSIX compliance in
the first place... ;-)

Otherwise, LGTM.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  reply	other threads:[~2013-07-10 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 19:58 [PATCH] scripts/config: use sed's POSIX interface Clement Chauplannaz
2013-07-10 20:38 ` Yann E. MORIN [this message]
2013-07-10 22:20   ` Clément Chauplannaz

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=20130710203829.GD3297@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=ak@linux.intel.com \
    --cc=chauplac@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox