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

can't find wildcard file names on Cygwin #263

Closed
VladimirAlexiev opened this issue Sep 3, 2018 · 6 comments
Closed

can't find wildcard file names on Cygwin #263

VladimirAlexiev opened this issue Sep 3, 2018 · 6 comments
Labels
help wanted Extra attention is needed windows Issue is related to the Windows build of bat

Comments

@VladimirAlexiev
Copy link

Windows 10, cygwin

$ bat /cygdrive/c/prog/bin/*.pl
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)
[bat error]: The system cannot find the path specified. (os error 3)

There are that many files, so it gets the globbled listing but for some reason can't open the files.

Trying with one of them:

$ cat /cygdrive/c/prog/bin/rncfix.pl
#!perl -wp0
...
$ bat /cygdrive/c/prog/bin/rncfix.pl
[bat error]: The system cannot find the path specified. (os error 3)
@VladimirAlexiev
Copy link
Author

If I go to that folder, it opens the file:

$ cd /cygdrive/c/prog/bin/
$ bat rncfix.pl
#!perl -wp0

@sharkdp sharkdp added help wanted Extra attention is needed windows Issue is related to the Windows build of bat labels Sep 3, 2018
@sharkdp
Copy link
Owner

sharkdp commented Sep 3, 2018

Thank you for your feedback.

This isn't about wildcards. The problem is that bat cannot read a path like

/cygdrive/c/prog/bin/rncfix.pl

because it is not a valid Windows path. ripgrep has a similar problem (see BurntSushi/ripgrep#269).

I personally won't work on this (see my comment in #210), but if someone wants to tackle this, I'm happy to accept a PR if the solution doesn't add a lot of code (especially platform-dependent).

As a workaround, I guess you can call cygpath to translate the path to a Windows path and use that to call bat.

@eth-p
Copy link
Collaborator

eth-p commented Sep 7, 2018

@VladimirAlexiev I can't confirm this actually works on cygwin since I don't use it, but I wrote a quick bash function that should suffice as a workaround. Just add it to your .bash_profile:

bat() {
    local index
    local args=("$@")
    for index in $(seq 0 ${#args[@]}) ; do
        case "${args[index]}" in
        -*) continue;;
        *)  [ -e "${args[index]}" ] && args[index]="$(cygpath --windows "${args[index]}")";;
        esac
    done
    command bat "${args[@]}"
}

@sharkdp
Copy link
Owner

sharkdp commented Sep 12, 2018

@VladimirAlexiev Any update on this?

@VladimirAlexiev
Copy link
Author

If I try with Windows path syntax, I get this (in both CMD and bash):

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

If I try with your function, it finds the files.

@sharkdp
Copy link
Owner

sharkdp commented Sep 14, 2018

With @eth-p's workaround successfully tested, I will close this as I currently don't have the intention to add cygwin-specific code to bat.

@VladimirAlexiev Your wildcard issue is already tracked in #309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed windows Issue is related to the Windows build of bat
Projects
None yet
Development

No branches or pull requests

3 participants