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

WISH: Add built-in globbing on Windows #5913

Open
HenrikBengtsson opened this issue May 22, 2016 · 8 comments
Open

WISH: Add built-in globbing on Windows #5913

HenrikBengtsson opened this issue May 22, 2016 · 8 comments
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community topic/windows Windows specific

Comments

@HenrikBengtsson
Copy link

On Windows 7 Ultimate 64-bit with NTFS, ipfs add gives an error when trying to add files using wildcard / globbing, e.g. ipfs add * and ipfs add *.txt.

Example

c:\tmp> echo Hello > hello.txt
c:\tmp> ipfs add *
Error: GetFileAttributesEx *: The filename, directory name, or volume label syntax is incorrect.
[...]

c:\tmp> ipfs add *.txt
Error: GetFileAttributesEx *.txt: The filename, directory name, or volume label syntax is incorrect.
[...]

c:\tmp> ipfs add .*.txt
Error: GetFileAttributesEx .*.txt: The filename, directory name, or volume label syntax is incorrect.
[...]

c:\tmp> ipfs version
ipfs version 0.4.2

c:\tmp> dir *
 Volume in drive C is Windows7_OS
 Volume Serial Number is ****-****

 Directory of C:\tmp

05/22/2016  09:53 AM    <DIR>          .
05/22/2016  09:53 AM    <DIR>          ..
05/22/2016  09:53 AM                 8 hello.txt
               1 File(s)              8 bytes
               2 Dir(s)   1,989,726,208 bytes free

It works when specifying the complete filename:

c:\tmp> ipfs add hello.txt
8 B / 8 B [========================================================] 100.00 % 0�
added QmSpPJmG5quyMoZDmZv9npYabmKBjkXS6Mfo2tQuz2UYP1 hello.txt

This works on Linux, e.g.

$ echo Hello > hello.txt
$ ipfs add *
added QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu hello.txt
$ ipfs version
ipfs version 0.4.2
@Kubuxu
Copy link
Member

Kubuxu commented Jul 1, 2016

It is because AFAIK Windows doesn't support globbing.

@HenrikBengtsson
Copy link
Author

I believe Windows's cmd.exe supports globbing, e.g.

Z:\home\JohnDoe>dir *.txt    
Volume in drive Z has no label.
Volume Serial Number is 0000-0000

Directory of Z:\home\JohnDoe

 6/10/2016   7:14 PM           156  NOTES.txt
       JohnDoe1 file                       156 bytes
       0 directories    435,023,372,288 bytes free

or are you saying that the shell itself does not pass the expanded *.txt (as multiple arguments) to the executable called?

@Kubuxu
Copy link
Member

Kubuxu commented Jul 1, 2016

Yes that I what I am saying.

@HenrikBengtsson
Copy link
Author

I see. So, I guess this issue now turned into a feature request asking for built-in support for globbing by ipfs. I'm not a golang user / develop so in case I have very little to contribute. Maybe,

func Glob(pattern string) (matches []string, err error)

of filepath is of use here?

@whyrusleeping
Copy link
Member

@HenrikBengtsson i think that does do what you want. We could probably detect glob characters in the input and call that on it if found.

@HenrikBengtsson HenrikBengtsson changed the title Windows: ipfs add * gives Error: GetFileAttributesEx * ... (wildcard; globbing) WISH: Add built-in globbing on Windows Jul 1, 2016
@HenrikBengtsson
Copy link
Author

That sounds great. (I'm becoming almost a full-time *nix user these days, but figured there are/will be lots on IPFS users on Windows too).

@Kubuxu
Copy link
Member

Kubuxu commented Jul 1, 2016

@whyrusleeping problem is that glob characters can be valid filenames, we could make heuristic that if there is no file like that we try to expand the globe.

@HenrikBengtsson
Copy link
Author

Under the assumption that all other shells do globbing for IPFS, would it make sense to only call Glob() on Windows? For instance, I'm pretty sure Windows will throw an exception if you try to create / write a file with name *.txt (not just from the shell).

@daviddias daviddias transferred this issue from ipfs/ipfs Jan 10, 2019
@Stebalien Stebalien added kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community labels Jan 10, 2019
@magik6k magik6k added help wanted Seeking public contribution on this issue topic/windows Windows specific labels Jan 11, 2019
@momack2 momack2 added this to Inbox in ipfs/go-ipfs May 9, 2019
@Stebalien Stebalien added help wanted Seeking public contribution on this issue and removed help wanted Seeking public contribution on this issue labels Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/enhancement A net-new feature or improvement to an existing feature need/community-input Needs input from the wider community topic/windows Windows specific
Projects
No open projects
Development

No branches or pull requests

5 participants