python 2.7.12 on Linux behaving differently than on Windows
steve+python at pearwood.info
Wed Dec 7 19:09:41 EST 2016
On Thu, 8 Dec 2016 02:48 am, BartC wrote:
> On 07/12/2016 13:58, Dennis Lee Bieber wrote:
>> On Wed, 7 Dec 2016 11:54:35 +0000, BartC <bc at freeuk.com> declaimed the
>>> With automatic expansion, then EVERY program can become dangerous. Can
>>> no one else see this?
>> With your scheme, EVERY PROGRAM HAS TO IMPLEMENT ITS OWN GLOBBING.
> Only the tiny minority that can be meaningfully invoked on an arbitrary
> number of files at the same time.
Its not just filename globbing. There's tilde expansion, brace expansion,
arithmetic expansion, parameter expansion, variable expansion, and I dare
say I've forgotten some others.
[steve at ando ~]$ echo ~
[steve at ando ~]$ echo $((1+7*5))
[steve at ando ~]$ echo $http_proxy
The echo command doesn't have to understand anything about tildes, contain
its own arithmetic expression evaluator, or even be able to parse variable
names. The shell does all that for it.
Filename globbing was just a simple example that would be familiar to
everyone discussing the topic. But the full range of expansions performed
is much, much richer than that.
> You make it sound like a big deal. Here's a program (in my language not
> Python) which prints the list of files matching a file-spec:
> println dirlist(cmdparams)
Does dirlist provide an escaping mechanism so that you can disable filename
globbing? In another post, you claimed that in your programs, you wouldn't
use anything as clumsy and ambiguous as globbing.
My program wouldn't need anything so crude. The input syntax
would be more carefully designed so as to not have the ambiguity.
So presumably your dirlist() command can distinguish between the file called
literally "*.*" and the file spec "*.*" that should be expanded, only of
course you don't actually use globbing syntax, as that's too crude, you use
your own ever-so-clever syntax which is completely ambiguity free.
And of course your program is also capable of variable and arithmetic
[steve at ando ~]$ export base="thefile"
[steve at ando ~]$ ls -l "$base$((1000 + 234))"
-rw-rw-r-- 1 steve steve 0 Dec 8 10:51 thefile1234
> (Here are implementations of that dirlist() for both OSes:
I have no idea how good the Windows globbing support is, or whether it can
be escaped. (Presumably its unambiguous because * ? [ ] are not legal in
Windows file names?)
For the Linux implementation, I don't see how extractpath and extractfile
are defined, or fnmatch, so who knows how many bugs are in your globbing
I see no obvious way of disabling globs across the entire command line,
equivalent to the bash "setopt -o noglob".
I see no brace expansion.
I see no arithmetic expansion.
I see no variable expansion.
I don't even see partial support for ~ expansion, let alone full support.
Looks like you have a lot of wheels that need re-inventing before you come
even close to parity with the features of the Linux shell.
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list