python 2.7.12 on Linux behaving differently than on Windows

BartC bc at freeuk.com
Tue Dec 6 08:52:20 EST 2016


On 06/12/2016 13:34, Chris Angelico wrote:
> On Wed, Dec 7, 2016 at 12:25 AM, BartC <bc at freeuk.com> wrote:
>> What, the convention of NOT assuming that any command parameter that uses *
>> or ? MUST refer to whatever set of filenames happen to match in the current
>> directory? And to then insert N arbitrary filenames in the parameter list.
>>
>> That's a pretty good convention, yes?!
>
> Right! And while you're at it, stop assuming that percent signs have
> meaning, that quotes have meaning, etc, etc, etc. Right? And why
> should the enter key be significant - what if you want to send more
> than one line of command line arguments?

But those would be silly.

Some special syntax is known about: | < and > for example. % less so 
(I've never, ever used it in live input AFAIK).

This auto-expansion causes so many problems, places so many restrictions 
on what can be done, that it doesn't make sense. Auto-expanding 
parameters is such a big deal, that it should not be the default 
behaviour; it needs something to tell the command processor to expand.

Then you don't get utterly ridiculous and dangerous behaviour such as 
the cp example Paul Moore came up with (that trumps most of mine actually):

Start with a directory containing two files c.c and d.c. You want to 
copy all .c files elsewhere, but accidentally type this:

    > cp *.c

which ends up doing:

    > cp c.c d.c

cp (or a program wanting to do anything like this) expects two arguments 
to be entered. But with auto-expansion, that is impossible to determine.

And the justification? Well, %ENVIRONMENTVARIABLE% gets converted in 
Windows, so why not?!

-- 
Bartc



More information about the Python-list mailing list