Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle wildcards on Windows CMD #309

Closed
VladimirAlexiev opened this issue Sep 13, 2018 · 8 comments
Closed

handle wildcards on Windows CMD #309

VladimirAlexiev opened this issue Sep 13, 2018 · 8 comments
Labels
feature-request New feature or request good first issue Good for newcomers windows Issue is related to the Windows build of bat

Comments

@VladimirAlexiev
Copy link

When I try this from Windows CMD:

>cd c:\prog\bin
>bat *.pl
[bat error]: The filename, directory name, or volume label syntax is incorrect. (os error 123)

The same error if I give a path. So it seems to me it doesn't handle the wildcard at all.

@eth-p
Copy link
Collaborator

eth-p commented Sep 14, 2018

If I recall correctly, wildcard expansion isn't a part of the Windows CMD shell. I believe it's left up to the program to handle that itself.

@sharkdp Any ideas on whether this feature should be added, and if so, how to avoid breaking compatibility with other shells (e.g. bat "my-file-with-a-*-in-it.txt" in bash)?

@sharkdp sharkdp added question Further information is requested windows Issue is related to the Windows build of bat labels Sep 14, 2018
@sharkdp
Copy link
Owner

sharkdp commented Sep 14, 2018

@eth-p is correct. cmd.exe and PowerShell will not expand wildcards by default and therefore leave it up to the application to interpret wildcard characters: https://superuser.com/q/56918/723625

As I said in my comment here, I don't have any intention to support cmd.exe. In PowerShell, you can use a subshell as a workaround:

bat $(ls *.pl)

If we want to support this natively, we could think about using this crate.

@sharkdp
Copy link
Owner

sharkdp commented Sep 23, 2018

@VladimirAlexiev Any update on this?

@VladimirAlexiev
Copy link
Author

@sharkdp I'm not a linux or cygwin programmer, but most cygwin programs support wildcard expansion, so I guess that's easy to do on cygwin. I don't think each linux program was individually ported to cygwin. Eg here's ls and grep running in CMD.

>cd \prog\bin

>ls *.pl
cleanup-RFC.pl  filever-ren.pl    lib2txt.pl   pfind.pl   prefixize.pl  reg-hack.pl  rncfix.pl   search.pl
exetype.pl      html-unescape.pl  perlglob.pl  pl2bat.pl  rdfpretty.pl  riotval.pl   runperl.pl  xmlpp.pl

>grep -i -c perl *.pl
cleanup-RFC.pl:1
exetype.pl:3
filever-ren.pl:1
html-unescape.pl:1
lib2txt.pl:3
perlglob.pl:9
pfind.pl:15
pl2bat.pl:63
prefixize.pl:2
rdfpretty.pl:2
reg-hack.pl:1
riotval.pl:1
rncfix.pl:1
runperl.pl:15
search.pl:25
xmlpp.pl:1

@sharkdp
Copy link
Owner

sharkdp commented Sep 25, 2018

Why are you switching the discussion to Cygwin now?

Cygwin (I believe) uses bash as a shell which will do a proper wildcard expansion. My guess would be that bat *.pl would also work in the cygwin shell?

@VladimirAlexiev
Copy link
Author

Cygwin is not related to bash. Cygwin is a set of libraries for easy porting of unix programs on windows.
All cygwin ports correctly expand wildcards in CMD, so I guess it's really easy to do this (just a matter of proper building).

@sharkdp
Copy link
Owner

sharkdp commented Sep 26, 2018

So you are calling "cygwin programs" from CMD? In this case, I guess there are special versions which are built for cygwin because CMD definitely doesn't do any wildcard expansion.

As I said above, I think there is a really easy way to fix this by using the wild crate. I'm going to turn this into a feature request.

@sharkdp sharkdp added feature-request New feature or request good first issue Good for newcomers Hacktoberfest and removed question Further information is requested labels Sep 26, 2018
richardhozak pushed a commit to richardhozak/bat that referenced this issue Oct 2, 2018
Windows does not support wildcard expansion in cmd,
this adds 'wild' crate that handles everything transparently,
so wildcards work everywhere.

Fixes sharkdp#309
richardhozak pushed a commit to richardhozak/bat that referenced this issue Oct 3, 2018
Windows does not support wildcard expansion in cmd,
this adds 'wild' crate that handles everything transparently,
so wildcards work everywhere.

Fixes sharkdp#309
sharkdp pushed a commit that referenced this issue Oct 3, 2018
Windows does not support wildcard expansion in cmd, this adds 'wild' crate (as discussed in #309) that handles everything transparently, so wildcards work everywhere.

Fixes #309
@sharkdp
Copy link
Owner

sharkdp commented Oct 17, 2018

Released in v0.8.0. @VladimirAlexiev Could you please test this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request good first issue Good for newcomers windows Issue is related to the Windows build of bat
Projects
None yet
Development

No branches or pull requests

3 participants