git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Konstantin Khomoutov <kostix@bswap.ru>
Cc: git@vger.kernel.org
Subject: Re: [RFC] shell: local x=$1 may need to quote the RHS
Date: Tue, 25 Jan 2022 11:00:39 -0800	[thread overview]
Message-ID: <xmqqa6fjzlm0.fsf@gitster.g> (raw)
In-Reply-To: <20220125092419.cgtfw32nk2niazfk@carbon> (Konstantin Khomoutov's message of "Tue, 25 Jan 2022 12:24:19 +0300")

Konstantin Khomoutov <kostix@bswap.ru> writes:

> Sorry, I might have not followed the entire thread, but assignment in
> `local` is a bashism, and dash can only handle the declaration part with
> `local`, not assignment; hence the safe code should read
>
>   local x
>   x="$1"

Interesting.  As "local" is not in POSIX but we still use it for
convenience, we must limit our use to a reasonable subset of
features common to the shells we care about.  Knowing what each
shell can and cannot do safely is essential to us.

The patch posted seemed to run fine with a more recent dash than
what I had trouble with (0.5.10 would work fine with "$1" quoted,
0.5.11 would work fine without $1, just like the RHS of a regular
assignment).  In addition, there are many existing tests that
already use "local var=initial-value" (the message you are
responding to has an output from "grep") and we haven't got problem
reports from dash users about them.

The manual page for recent dash may need an update.
Can you perhaps file a bug on their documentation?

Thanks.

  reply	other threads:[~2022-01-25 19:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 20:11 [RFC] shell: local x=$1 may need to quote the RHS Junio C Hamano
2022-01-25  9:24 ` Konstantin Khomoutov
2022-01-25 19:00   ` Junio C Hamano [this message]
2022-01-25 20:19     ` Taylor Blau
2022-01-26  5:53       ` Junio C Hamano
2022-01-26 11:39         ` Konstantin Khomoutov
2022-01-26 21:48         ` SZEDER Gábor
2022-01-26 21:52         ` Taylor Blau
2022-01-27  0:17           ` Junio C Hamano

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=xmqqa6fjzlm0.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kostix@bswap.ru \
    /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;
as well as URLs for NNTP newsgroup(s).