python 2.0 won't run scripts with \r\n line termination on RH7?

Remco Gerlich scarblac at pino.selwerd.nl
Wed Feb 14 19:19:29 EST 2001


Mike Carifio <carifio.nospam at nospam.usys.com> wrote in comp.lang.python:
> If bash accomodated both \r\n and \n at the end of the first line, I 
> wouldn't be asking the question because it wouldn't matter. It would 
> just work.

It's not bash doing that, it's the Linux kernel. And for all it knows,
you're just asking for a file that ends with \r, which is perfectly legal.
Actually, files with \n in them are perfectly legal as well but they won't
work with a #! line I think, so maybe you have a point... But it has to work
this way to be compatible with Unix.

>From a distance I'd guess the chance of the Linux kernel understanding
Windows text files for #! in the near future is extremely close to 0...

> In any event, the original question was "are there work arounds?" To
> summarize the answers:
> 
> 1) Yes, but the workarounds are crufty. Obey the \n rule. In some cases, you
> can get your favorite editor
>      or IDE to do it for you regardless of platform.
> 2) You can graft \r onto the python filename. Pro: you can create scripts
> from Windows or Linux on the native
>      file system or over Samba. Cons: You can't pass additional arguments,
> it leaves a foul taste in your mouth.
> 3) If you put your scripts under source code control, you can convert end of
> line on checkout.

I'd say run a utility that mass converts your files after you move them to
the linux server. Also, if you move them by ftp in ASCII mode, it will
convert the files.

-- 
Remco Gerlich



More information about the Python-list mailing list