[Mingw-users] Shell is stripping curly braces in Git for Windows

Back to archive index

Keith Marshall keith****@users*****
Sun Apr 15 03:42:54 JST 2018


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/04/18 18:01, Eli Zaretskii wrote:
>> From: Keith Marshall <keith****@users*****> Date: Sat, 14 Apr 2018
>> 11:13:16 +0100
>> 
>>>> $ git myalias @{-1}
>> 
>> What is the shell?  If its GNU bash, (as our MSYS shell would
>> be), then braces are special; bash performs brace expansion on
>> the comma separated list within them, (and in this case, there's
>> only one item in the list).  You need to quote the final
>> argument, to suppress the effect of brace expansion.
>> 
>>>> This results in:
>>>> 
>>>> "git myalias @-1"
>> 
>> This is exactly the result I would expect, after brace expansion
>> of the single item list "-1".
> 
> FWIW, invoking this command in MSYS Bash:
> 
> $ echo @{-1}
> 
> yields @{-1}, i.e. no expansion happens.

I stand corrected; I see the same, both with MSYS bash, and with the
bash-4.3.25 on my LinuxMint (LMDE) box.  It appears that brace
expansion is activated only when there is at least one comma within a
pair of braces.  However ...

> Moreover, if I invoke a MinGW program with this argument, it
> receives the literal @{-1} as well in its argv[] array.

... while that may be true when brace expansion has not been enabled,
(by default, it is not), I do see two bugs in mingwrt's implementation
of glob(3), when the feature is enabled:

  $ cmd
  Microsoft Windows XP [Version 5.1.2600]
  (C) Copyright 1985-2001 Microsoft Corp.

  C:\mingw\msys\1.0\home\keith> showargv @{-1}
  command: showargv @{-1}
  argv[00]: showargv
  argv[01]: @-1

Note, that brace expansion has occurred, although there is no comma
within the brace expression; moreover, quoting the argument doesn't
prevent it, (as it should):

  C:\mingw\msys\1.0\home\keith> showargv "@{-1}"
  command: showargv "@{-1}"
  argv[00]: showargv
  argv[01]: @-1

  C:\mingw\msys\1.0\home\keith> showargv '@{-1}'
  command: showargv '@{-1}'
  argv[00]: showargv
  argv[01]: @-1

So, we appear to be back to your original assertion that, if git for
windows uses some other implementation, we need not be concerned,
since our MSYS bash shell seems to DTRT.  However, the bug which is
apparent in mingwrt's glob(3) does merit investigation.

- -- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJa0kuuAAoJEMCtNsY0flo/H5QQALR2BKh9fyXILjJ+JmFG4lMt
ORDv28rp/HPOG5l0ZthjfaizSLZEJYGB+oHpNUxTvhIx+x+L9LY5l2oGnd2ylS0g
kQqFkm3aXwaG2p9XRlWomiY4P/fSg1CtALkwt3OO2mnQya2eBco9povjXRX4b0Au
qTII/XtefFRQfv7BXHNLMXUGOIjUMg4MuJx4vHOF/bVp5kmt0Y03STawfv1jNKdr
VZSbNn2peD32RFZMeJVON7KqY+CRVxx+SpEQLjPK5N1LNDNIsPiLlA0MhbYkXHQK
9AR3xNZwg3EoQ99imAnnOQWSR9GVSkMQlIw7JStj1MVSeJ6UAkkOVgwrq1IbWRRK
SfA6XpefzQTw8wW0KPw0kDdEI/aezS+knGztsYRQLuucy1CeLx+1pwcgAq3neKBu
8Ne7s/ksxA/Q1bIVnRVGpk6ro6KVoMNXDTu8wUe2pzOTUXviAI5C3Wk4lVoT89WS
KmIbZyPfyzvxA6G9ttcTVjg8+M+GluZbE8fphK6Ilw+7RVZFZmDIrF1UzH9npVqj
qY7YUpo10hWc2xDxyCi+BUx6hGQrvYccMrtzG7kALSP0SggKabVZwOEob5OvYKYs
xjGtrAdSeNCCg5meE6zdd5Svl2RTiwedCD5Vy6I1ANXy00cEf0zkXlwJd8W39U4R
1Y7eiuFe5gG9ipWxXs4A
=WGct
-----END PGP SIGNATURE-----




More information about the MinGW-Users mailing list
Back to archive index