Skip to content

pr-913/adlternative/trailer-pass-ARG-env-v6

From: ZheNing Hu <adlternative@gmail.com>

The `trailer.<token>.command` configuration variable
specifies a command (run via the shell, so it does not have
to be a single name of or path to the command, but can be a
shell script), and the first occurrence of substring $ARG is
replaced with the value given to the `interpret-trailer`
command for the token.  This has two downsides:

* The use of $ARG in the mechanism misleads the users that
the value is passed in the shell variable, and tempt them
to use $ARG more than once, but that would not work, as
the second and subsequent $ARG are not replaced.

* Because $ARG is textually replaced without regard to the
shell language syntax, even '$ARG' (inside a single-quote
pair), which a user would expect to stay intact, would be
replaced, and worse, if the value had an unmatching single
quote (imagine a name like "O'Connor", substituted into
NAME='$ARG' to make it NAME='O'Connor), it would result in
a broken command that is not syntactically correct (or
worse).

Introduce a new `trailer.<token>.cmd` configuration that
takes higher precedence to deprecate and eventually remove
`trailer.<token>.command`, which passes the value as a
parameter to the command.  Instead of "$ARG", the users will
refer to the value as positional argument, $1, in their
scripts.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: ZheNing Hu <adlternative@gmail.com>

Submitted-As: https://lore.kernel.org/git/pull.913.v6.git.1617369973328.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.git.1616511182942.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.v2.git.1616600555906.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.v3.git.1616673200809.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.v4.git.1616775185562.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.913.v5.git.1617185147.gitgitgadget@gmail.com
Assets 2