python 2.7.12 on Linux behaving differently than on Windows

Michael Torrie torriem at gmail.com
Wed Dec 7 12:19:27 EST 2016


On 12/07/2016 07:57 AM, BartC wrote:
> I don't follow you. "?" is problematical on both systems. I think 
> Windows disallows it completely: I get 'Protocol error' if I copy such a 
> file from Linux to Windows. Presumably there is an escaping system, but 
> I don't know what it is.

As Chris says, no it's not problematical. Only / and null are not
allowed in filenames on Unix (Posix) systems including Linux.  Many
filename characters do have special meaning to shells, so they must be
escaped when specifying them on a shell prompt (but they don't have to
be escaped if another program is calling the program with popen).

> But we're talking about Linux. Obviously if a program is developed on 
> Linux, can work on multiple files and DEPENDS on on being presented with 
> that list of files as though it had been invoked as:
> 
>    program file1 file2 file3 file4 file5 file6 file7 .... fileN
> 
> then it will have problems if that feature is taken away. I can see how 
> it can still be there after all these years!

40 years is a long time, plenty of time to change what doesn't work.

This idea of specifying multiple files individually on a command-line
not only works, it's there for good reason.  I've alluded to it several
times. This idea is part of how we can string together small scripts to
do batch processing and filtering (of data or files or whatever) using
the shell.  You could say it's part of the interprocess communication
protocol that shell scripting relies upon.  Globbing by each individual
app would break this protocol and make it harder to string these bits
and bobs together.  This protocol involves piping of standard in and
standard out, or to pipe the output from one command onto the
command-line of another app (multiple channels).  This is the power of
the unix shell and this is why I and many others use it for our daily
work every day.  And this is why these concepts that trip you up have
had such staying power.  We simply haven't found a better way of doing
it.  Also the unix shell protocol and ideal allows you to completely
replace the shell with something else, and the scripts processes one has
developed still function!  C Shell, Bourne shell, Bash, zsh, fish.  Just
pick the one you want (each with their own quirks and expansion rules
and quoting and escaping rules).

I've seen attempts as using something based on Python to form a shell,
but ultimately they never feel quite right to me.  Mainly because
there's an impedance mismatch between python's objects and files on a
filesystem. Does such an impedance mismatch come with PowerShell too? I
dunno.



More information about the Python-list mailing list