python 2.7.12 on Linux behaving differently than on Windows

BartC bc at freeuk.com
Wed Dec 7 10:19:53 EST 2016


On 07/12/2016 14:34, Steve D'Aprano wrote:
> On Wed, 7 Dec 2016 11:23 pm, BartC wrote:
>
>> On 07/12/2016 05:15, Steven D'Aprano wrote:
>>> On Wednesday 07 December 2016 12:55, BartC wrote:
>>>
>>>> But even Linux's 128KB will fill if someone wanted a command line that
>>>> listed 20,000 files individually. But it would be spectacularly bad use
>>>> of a command line interface which was designed for humans.
>>>
>>> That's EXACTLY the point of having the shell do globbing.
>>
>> Sorry, it's got NOTHING to do with it!
>>
>> Here's a command that works on all one million files in the current path:
>>
>>   program *.*

>> 11 characters, so Linux still has 131061 left (assuming 'program ' is
>> part of it).
>
> I don't know why you are so hung up over the number of characters here, or
> this bogeyman of "one million files" in a directory.

Because /you/ brought it up as a reason why 'globbing' would help when 
there are command limits?

  Who does such a thing?
> Most sys admins will go their entire career without ever needing to process
> a million files in a single directory, or even split over a dozen
> directories.

They probably never need to use a 128KB command line either.

> But... how does your program distinguish between the file spec *.* which
> should be expanded, and the literal file *.* which shouldn't be expanded?

Do you mean a *.* parameter that refers to all the files in the 
directory (whether the intention is to build a list of those files or 
not) and a *.* parameter that means something entirely different?

OK, but you go first: how does a Linux program tell the difference between:

   A B C

which signifies three files, and:

   A B C

which means two files, and an option C? And without using escapes!

> You need an escape mechanism too. You've done that, of course. Right?

My program wouldn't need anything so crude. The input syntax would be 
more carefully designed so as to not have the ambiguity.

And actually I generally avoid command line interfaces (ones used by 
shells) because they are such a pain. (Why, for example, aren't the 
contents of the command line - even after preprocessing by the shell - 
just read using exactly the same mechanism as subsequent lines of input?)

>>    list fooba?.jpg {here,there}/*.jpg  another/place/*.{png,jpg} \
>>      [a-z]/IMG* > files
>>
>>    command @files
>
> *Requiring* this would be completely unacceptable. Forcing the user to write
> two lines (one to create a variable, then to use it) every time they needed
> a glob expansion would go down among sys admins like a lead balloon.

Suppose there is a pattern that can't be expressed as a one-liner?

And the shell is supposed to be a full-fledged programming language, 
people keep saying. What can be more natural than to make use of 
variables? As you go on to demonstrate!

-- 
Bartc




More information about the Python-list mailing list