From: Jeff King <peff@peff.net>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: "Torsten Bögershausen" <tboegi@web.de>,
"Junio C Hamano" <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: [PATCH 1/4] t0021: use write_script to create rot13 shell script
Date: Sun, 6 Nov 2016 09:29:58 -0500 [thread overview]
Message-ID: <20161106142957.52wx2llanw5bis4i@sigill.intra.peff.net> (raw)
In-Reply-To: <22DAA280-1857-4E22-914A-1208D784DA98@gmail.com>
On Sun, Nov 06, 2016 at 03:25:33PM +0100, Lars Schneider wrote:
> This looks good to me (and it works on my machine).
> However, I took a look at the "write_script" function and found this,
> added by Junio in 840c519d:
>
> echo "#!${2-"$SHELL_PATH"}" &&
>
> There is some kind of variable expansion happening with the "2-" but
> I can't quite figure out what is going on. Plus, I can't find anything
> about this in the sh docs.
>
> Can anyone help me to understand it?
See the section on parameter expansion in "man bash". Basically:
${foo:-bar}
expands to $foo, or "bar" if it is unset or empty. Without the colon:
${foo-bar}
expands to $foo, "bar" if it unset (but not if it is empty). I don't
think we really care about the distinction here, and either is fine (you
would not ever pass an empty argument).
So in this context you may pass in the interpreter:
write_script "$PERL_PATH" <<\EOF
... some perl code ...
EOF
or it defaults to shell, which is what most of the callers want:
write_script <<\EOF
... some shell code ...
EOF
-Peff
next prev parent reply other threads:[~2016-11-06 14:30 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-31 21:49 What's cooking in git.git (Oct 2016, #09; Mon, 31) Junio C Hamano
2016-11-02 7:16 ` Torsten Bögershausen
2016-11-02 12:55 ` Junio C Hamano
2016-11-02 9:57 ` Johannes Schindelin
2016-11-02 12:57 ` Junio C Hamano
2016-11-02 17:04 ` Torsten Bögershausen
2016-11-02 17:40 ` Jeff King
2016-11-02 18:16 ` [PATCH 0/4] t0021 perl portability fixups Jeff King
2016-11-02 18:17 ` [PATCH 1/4] t0021: use write_script to create rot13 shell script Jeff King
2016-11-06 14:25 ` Lars Schneider
2016-11-06 14:29 ` Jeff King [this message]
2016-11-06 14:43 ` Lars Schneider
2016-11-02 18:18 ` [PATCH 2/4] t0021: put $TEST_ROOT in $PATH Jeff King
2016-11-03 20:40 ` Johannes Sixt
2016-11-03 20:44 ` Jeff King
2016-11-03 21:09 ` Johannes Sixt
2016-11-06 14:29 ` Lars Schneider
2016-11-02 18:20 ` [PATCH 3/4] t0021: use $PERL_PATH for rot13-filter.pl Jeff King
2016-11-06 14:52 ` Lars Schneider
2016-11-06 14:54 ` Jeff King
2016-11-02 18:23 ` [PATCH 4/4] t0021: fix filehandle usage on older perl Jeff King
2016-11-02 20:54 ` Torsten Bögershausen
2016-11-06 14:55 ` Lars Schneider
2016-11-02 17:43 ` What's cooking in git.git (Oct 2016, #09; Mon, 31) Johannes Sixt
2016-11-03 14:21 ` Lars Schneider
2016-11-02 17:44 ` Lars Schneider
[not found] ` <CAG2PGspq34wn2bAGyhR6B-XmmayadmL-v3_65y5LJWTWNHXkOQ@mail.gmail.com>
2016-11-05 7:27 ` Torsten Bögershausen
2016-11-05 7:42 ` Torsten Bögershausen
2016-11-08 8:12 ` Karthik Nayak
[not found] ` <CA+P7+xo+CJU_ng5OWX1y26+=QPCg6Zxpv_0opTAzsNqeFXAwng@mail.gmail.com>
2016-11-08 9:03 ` Karthik Nayak
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161106142957.52wx2llanw5bis4i@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=larsxschneider@gmail.com \
--cc=tboegi@web.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).