python 2.7.12 on Linux behaving differently than on Windows
steve+python at pearwood.info
Sun Dec 4 18:25:11 EST 2016
On Mon, 5 Dec 2016 09:19 am, BartC wrote:
> Command parameters /do/ behave differently between Windows and Linux,
> for example try writing *.* as that third parameter.
> In Windows, it will print *.*.
> In Linux, if you have 273 files in the current directory, if will print
> the name of the first, and there will be /272 further command
> parameters/, each the name of a file. (I couldn't believe this when I
> found out; one of my directories recently had 3.4 million files in it, I
> don't really want *.* expanded to 3.4m arguments. Here, the fix is again
> to use double quotes: "*.*". But what if the user doesn't do that?)
If the user doesn't escape the wildcard, then the shell will expand it,
exactly as the user would expect.
I'm not sure why you were surprised by that. * is a shell wildcard. By using
a * you are explicitly telling the shell to expand it to any file that
matches. Did you think it was a regular character like 'a' and 'z'?
I think it boils down to what the user expects. Linux and Unix users tend to
be technically-minded folks who use the command line a lot and demand
powerful tools, and they expect that wildcards like * should be expanded.
Windows treats the command line as an afterthought, and until a few years
ago you were limited to a DOS shell. Today, your options are not as
limited: there's Powershell, and bash for Windows.
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list