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 <b...@freeuk.com> declaimed the >> following: >> >>> 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@ando ~]$ echo ~ /home/steve [steve@ando ~]$ echo $((1+7*5)) 36 [steve@ando ~]$ echo $http_proxy http://ando:3128 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[2]) 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. Right? And of course your program is also capable of variable and arithmetic expansion, right? [steve@ando ~]$ export base="thefile" [steve@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: > http://pastebin.com/knciRULE 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 implementation. 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. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list