Why does globbing not work on ported Linux tools, but work on Windows ones? #548
-
I know that this isn't to do with clink, as it happens without clink too, but if this does not involve readline on Linux, I don't know what it does involve. On Linux shells and in cmd.exe when using native Windows commands, glob characters like I thought this may be a good place to ask this. Isn't it something that clink could make work? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Short version:In Unix/Linux the shell does it; but in Windows CMD doesn't expand wildcards. Ported Linux apps work on Windows the same as they do on Linux. The apps don't expand wildcards. The difference in behavior happens when they aren't launched from a Linux shell. More info:There are lots of articles and questions/answers on this topic on the internet, findable via internet searches. Here's another. 🙃 In Unix/Linux the shells interpret wildcards, and the shells expand them before launching an app. In CMD on Windows, the shell does not expand wildcards before an app. So if ported Linux apps are run from a Linux shell like bash or zsh or etc, then the shell does the wildcard expansion and the overall experience is the same as on Linux. But if the app is run from CMD, then only half of the ported experience is happening -- since shells in Linux are what expand (unquoted) wildcards, and CMD does not expand wildcards, the ported Linux apps receive the command from CMD without wildcards expanded. By the way, here are a couple of interesting caveats/problems with the Linux shell approach to wildcard expansion:
Linux and Windows have different paradigms for who is responsible for wildcard expansion. Neither way is "right" or "wrong", and each way has benefits and drawbacks -- they're just different ways. IIRC, the main reason Windows CMD doesn't expand wildcards is because DOS and Windows aimed at having familiarity/compatibility with CP/M (and maybe also VAX/VMS, though I don't remember offhand whether VMS expanded wildcards in its shell, and I couldn't quickly find an answer via internet searches).
When should it expand wildcards, and when should it not? If it expands wildcards before launching ported linux programs, then ok fine. You could write a Lua script to expand wildcards. The key would be using clink.onfilterinput(). You can try to find a way to predict when it's reasonable to expand wildcards. |
Beta Was this translation helpful? Give feedback.
-
P.S. MSVC has an optional way to compile a program, that makes the C runtime expand wildcards in the command line before the program actually receives the command line. It can be used to make a program behave similar to as if it were launched from a Linux shell. Typically, when programs are compiled using that optional mode it creates confusion and quirky edge case problems, but the mode exists and is possible for an app author to use if they wish. |
Beta Was this translation helpful? Give feedback.
Short version:
In Unix/Linux the shell does it; but in Windows CMD doesn't expand wildcards.
Ported Linux apps work on Windows the same as they do on Linux. The apps don't expand wildcards. The difference in behavior happens when they aren't launched from a Linux shell.
More info:
There are lots of articles and questions/an…