{"thread":{"id":"51642","subject":"Potential asterisk expansion bug in Windows Git Bash?","startedAt":"2019-08-14T11:51:00Z","lastAt":"2019-08-14T12:38:32Z","messageCount":3,"participants":["Bo Zhang","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"380435","messageId":"CAO=KXnspgZa=R9=8wvPY-Y8pvuAah-D+Jc4CM_+cdemYGUJ09A@mail.gmail.com","threadId":"51642","inReplyTo":null,"subject":"Potential asterisk expansion bug in Windows Git Bash?","fromName":"Bo Zhang","fromEmail":"zhangbodut@gmail.com","sentAt":"2019-08-14T11:50:47Z","receivedAt":"2019-08-14T11:51:00Z","isPatch":false,"sender":{"key":"zhangbodut@gmail.com","avatar":null},"body":"Hi there,\n\nNot sure if this is the correct channel to submit a bug report for\nWindows Git Bash. Please let me know if I did anything wrong.\n\nToday I noticed that on Windows Git Bash, the asterisk (*) is\nincorrectly expanded even when it’s in a quote or following a\nbackslash (\\). I’m wondering if this is the correct behaviour (which\nseems like to me NOT).\n\nStep to reproduce (in Windows git bash):\n\nzhb@zhb-PC MINGW64 ~/Desktop\n$ bash --version\nGNU bash, version 4.4.19(2)-release (x86_64-pc-msys)\nCopyright (C) 2016 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\nThis is free software; you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nzhb@zhb-PC MINGW64 ~/Desktop\n$ cat 1.sh\necho $1\n\nzhb@zhb-PC MINGW64 ~/Desktop\n$ bash 1.sh '*'\n$A 1.sh 1.txt\n\nzhb@zhb-PC MINGW64 ~/Desktop\n$ bash 1.sh \"*\"\n$A 1.sh 1.txt\n\nzhb@zhb-PC MINGW64 ~/Desktop\n$ bash 1.sh \\*\n1.sh 1.txt\n\nThank you very much.\n\nRegards,\nBo Zhang\n"},{"id":"380436","messageId":"20190814121045.GA30302@sigill.intra.peff.net","threadId":"51642","inReplyTo":"CAO=KXnspgZa=R9=8wvPY-Y8pvuAah-D+Jc4CM_+cdemYGUJ09A@mail.gmail.com","subject":"Re: Potential asterisk expansion bug in Windows Git Bash?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-14T12:10:46Z","receivedAt":"2019-08-14T12:10:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 14, 2019 at 07:50:47PM +0800, Bo Zhang wrote:\n\n> Today I noticed that on Windows Git Bash, the asterisk (*) is\n> incorrectly expanded even when it’s in a quote or following a\n> backslash (\\). I’m wondering if this is the correct behaviour (which\n> seems like to me NOT).\n> \n> Step to reproduce (in Windows git bash):\n> \n> zhb@zhb-PC MINGW64 ~/Desktop\n> $ bash --version\n> GNU bash, version 4.4.19(2)-release (x86_64-pc-msys)\n> Copyright (C) 2016 Free Software Foundation, Inc.\n> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n> \n> This is free software; you are free to change and redistribute it.\n> There is NO WARRANTY, to the extent permitted by law.\n> \n> zhb@zhb-PC MINGW64 ~/Desktop\n> $ cat 1.sh\n> echo $1\n\nYour script doesn't quote \"$1\", so whatever you pass in will be subject\nto wildcard expansion inside the shell running the script.\n\nTry this:\n\n  $ cat bad.sh\n  echo $1\n  $ cat good.sh\n  echo \"$1\"\n\n  $ bash bad.sh '*'\n  bad.sh good.sh\n\n  $ bash good.sh '*'\n  *\n\n> zhb@zhb-PC MINGW64 ~/Desktop\n> $ bash 1.sh '*'\n> $A 1.sh 1.txt\n\nSo this is the case I showed above.\n\n> zhb@zhb-PC MINGW64 ~/Desktop\n> $ bash 1.sh \"*\"\n> $A 1.sh 1.txt\n\nAnd this is equivalent. The quotes suppress wildcard expansion in your\ninteractive shell, but the script itself does another round of\nexpansion.\n\n> zhb@zhb-PC MINGW64 ~/Desktop\n> $ bash 1.sh \\*\n> 1.sh 1.txt\n\nAnd same here.\n\n-Peff\n"},{"id":"380437","messageId":"CAO=KXnvrVdTRW=FhKMixSHuR-qahJ2QqUKOn4PerZAVcxVJHww@mail.gmail.com","threadId":"51642","inReplyTo":"20190814121045.GA30302@sigill.intra.peff.net","subject":"Re: Potential asterisk expansion bug in Windows Git Bash?","fromName":"Bo Zhang","fromEmail":"zhangbodut@gmail.com","sentAt":"2019-08-14T12:38:18Z","receivedAt":"2019-08-14T12:38:32Z","isPatch":false,"sender":{"key":"zhangbodut@gmail.com","avatar":null},"body":"Thank you very much Jeff!\n\nIt turns out I ran into\nhttps://bugs.openjdk.java.net/browse/JDK-8131329 on Windows. The\nexample was also a mistake. Anyway, false alarm, thank you again!\n\nRegards,\nBo\n\nOn Wed, Aug 14, 2019 at 8:10 PM Jeff King <peff@peff.net> wrote:\n>\n> On Wed, Aug 14, 2019 at 07:50:47PM +0800, Bo Zhang wrote:\n>\n> > Today I noticed that on Windows Git Bash, the asterisk (*) is\n> > incorrectly expanded even when it’s in a quote or following a\n> > backslash (\\). I’m wondering if this is the correct behaviour (which\n> > seems like to me NOT).\n> >\n> > Step to reproduce (in Windows git bash):\n> >\n> > zhb@zhb-PC MINGW64 ~/Desktop\n> > $ bash --version\n> > GNU bash, version 4.4.19(2)-release (x86_64-pc-msys)\n> > Copyright (C) 2016 Free Software Foundation, Inc.\n> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n> >\n> > This is free software; you are free to change and redistribute it.\n> > There is NO WARRANTY, to the extent permitted by law.\n> >\n> > zhb@zhb-PC MINGW64 ~/Desktop\n> > $ cat 1.sh\n> > echo $1\n>\n> Your script doesn't quote \"$1\", so whatever you pass in will be subject\n> to wildcard expansion inside the shell running the script.\n>\n> Try this:\n>\n>   $ cat bad.sh\n>   echo $1\n>   $ cat good.sh\n>   echo \"$1\"\n>\n>   $ bash bad.sh '*'\n>   bad.sh good.sh\n>\n>   $ bash good.sh '*'\n>   *\n>\n> > zhb@zhb-PC MINGW64 ~/Desktop\n> > $ bash 1.sh '*'\n> > $A 1.sh 1.txt\n>\n> So this is the case I showed above.\n>\n> > zhb@zhb-PC MINGW64 ~/Desktop\n> > $ bash 1.sh \"*\"\n> > $A 1.sh 1.txt\n>\n> And this is equivalent. The quotes suppress wildcard expansion in your\n> interactive shell, but the script itself does another round of\n> expansion.\n>\n> > zhb@zhb-PC MINGW64 ~/Desktop\n> > $ bash 1.sh \\*\n> > 1.sh 1.txt\n>\n> And same here.\n>\n> -Peff\n"}]}