[Bug 4200] New: shell aliases should support interpolating "$@" the way POSIX shells do

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Thu Mar 20 19:21:15 CDT 2014


http://bz.selenic.com/show_bug.cgi?id=4200

          Priority: normal
            Bug ID: 4200
                CC: mercurial-devel at selenic.com
          Assignee: bugzilla at selenic.com
           Summary: shell aliases should support interpolating "$@" the
                    way POSIX shells do
          Severity: feature
    Classification: Unclassified
                OS: All
          Reporter: sid0 at fb.com
          Hardware: All
            Status: UNCONFIRMED
           Version: unspecified
         Component: Mercurial
           Product: Mercurial

The "$@" parameter in Bourne shells (at least) interpolates arguments while
splitting tokens in the way they were provided. In other words,  "$@" expands
to "$1" "$2"...

It is currently not possible to achieve this in Mercurial.

In a POSIX shell:

$ cat echotokens
#!/bin/sh
printf "%s\n" "$@"

$ ./echotokens foo 'bar $1 baz'
foo
bar $1 baz

In Mercurial, the closest equivalents are $@ (without quotes) and '$@' (with
single quotes). Neither of those are exact matches, however.

The following tests are with hg @ 43054dc84abd.

$ hg showconfig alias.echotokens
!printf "%s\n" $@
$ hg echotokens foo 'bar $1 baz'
foo
bar
baz

$ hg showconfig alias.echotokens
!printf "%s\n" '$@'
$ hg echotokens foo 'bar $1 baz'
foo bar $1 baz

$ hg showconfig alias.echotokens
!printf "%s\n" "$@"
$ hg echotokens foo 'bar $1 baz'
foo bar  baz

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list