Skip to content

Git Bash for Windows expands glob patterns even when quoted #1858

@bberstel

Description

@bberstel
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.19.0.windows.1
cpu: x86_64
built from commit: d96bb8bc6c636a8869140e860e72e7bdf64bd790
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17134.285]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: Notepad++
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: LFOnly
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Rebase: Disabled
Enable Builtin Stash: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Nope.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash

bruno@Oberkampf MINGW64 ~
$ cd tmp

bruno@Oberkampf MINGW64 ~/tmp
$ cat > foo.java
public class foo {
	public static void main(String[] args) {
		System.out.println(args.length + " args:");
		for (String arg: args) System.out.println(arg);
	}
}

bruno@Oberkampf MINGW64 ~/tmp
$ javac foo.java

bruno@Oberkampf MINGW64 ~/tmp
$ ll
total 9
-rw-r--r-- 1 bruno 197613 705 Oct  2 17:25 foo.class
-rw-r--r-- 1 bruno 197613 156 Oct  2 17:25 foo.java

bruno@Oberkampf MINGW64 ~/tmp
$ java foo
0 args:

bruno@Oberkampf MINGW64 ~/tmp
$ touch a.txt b.txt

bruno@Oberkampf MINGW64 ~/tmp
$ java foo *.txt
2 args:
a.txt
b.txt

bruno@Oberkampf MINGW64 ~/tmp
$ java foo "*.txt"
2 args:
a.txt
b.txt

bruno@Oberkampf MINGW64 ~/tmp
$ java foo '*.txt'
2 args:
a.txt
b.txt

bruno@Oberkampf MINGW64 ~/tmp
$ java foo \*.txt
2 args:
a.txt
b.txt

bruno@Oberkampf MINGW64 ~/tmp
$ java foo '*.txtd'
1 args:
*.txtd

  • What did you expect to occur after running these commands?

I would expect the glob patterns NOT to be expanded when quoted. Note that "*.txt" is not expanded when passed to echo or ls, but is when passed to the small Java program (and that program is so small that it cannot be suspected that it expands the pattern).

  • What actually happened instead?

The pattern was expanded, defeating the quotes around it.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

This is not dependent of a repo. Actually it seems independent from Git.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions