comparison mercurial/help/config.txt @ 22158:bc2132dfc0a4

alias: expand "$@" as list of parameters quoted individually (BC) (issue4200) Before this patch, there was no way to pass in all the positional parameters as separate words down to another command. (1) $@ (without quotes) would expand to all the parameters separated by a space. This would work fine for arguments without spaces, but arguments with spaces in them would be split up by POSIX shells into separate words. (2) '$@' (in single quotes) would expand to all the parameters within a pair of single quotes. POSIX shells would then treat the entire list of arguments as one word. (3) "$@" (in double quotes) would expand similarly to (2). With this patch, we expand "$@" (in double quotes) as all positional parameters, quoted individually with util.shellquote, and separated by spaces. Under standard field-splitting conditions, POSIX shells will tokenize each argument into exactly one word. This is a backwards-incompatible change, but the old behavior was arguably a bug: Bourne-derived shells have expanded "$@" as a tokenized list of positional parameters for a very long time. I could find this behavior specified in IEEE Std 1003.1-2001, and this probably goes back to much further before that.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 13 Aug 2014 23:21:52 -0700
parents d7f25834ffbb
children 9fa429723f26
comparison
equal deleted inserted replaced
22157:bd45d92883f9 22158:bc2132dfc0a4
227 repository in the same manner as the purge extension. 227 repository in the same manner as the purge extension.
228 228
229 Positional arguments like ``$1``, ``$2``, etc. in the alias definition 229 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
230 expand to the command arguments. Unmatched arguments are 230 expand to the command arguments. Unmatched arguments are
231 removed. ``$0`` expands to the alias name and ``$@`` expands to all 231 removed. ``$0`` expands to the alias name and ``$@`` expands to all
232 arguments separated by a space. These expansions happen before the 232 arguments separated by a space. ``"$@"`` (with quotes) expands to all
233 command is passed to the shell. 233 arguments quoted individually and separated by a space. These expansions
234 happen before the command is passed to the shell.
234 235
235 Shell aliases are executed in an environment where ``$HG`` expands to 236 Shell aliases are executed in an environment where ``$HG`` expands to
236 the path of the Mercurial that was used to execute the alias. This is 237 the path of the Mercurial that was used to execute the alias. This is
237 useful when you want to call further Mercurial commands in a shell 238 useful when you want to call further Mercurial commands in a shell
238 alias, as was done above for the purge alias. In addition, 239 alias, as was done above for the purge alias. In addition,