Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39602 > unrolled thread

Shebang line on Windows?

Started byWalter Hurry <walterhurry@lavabit.com>
First post2013-02-22 18:16 +0000
Last post2013-02-25 11:33 -0700
Articles 20 — 14 participants

Back to article view | Back to comp.lang.python


Contents

  Shebang line on Windows? Walter Hurry <walterhurry@lavabit.com> - 2013-02-22 18:16 +0000
    Re: Shebang line on Windows? Dave Angel <davea@davea.name> - 2013-02-22 13:40 -0500
    Re: Shebang line on Windows? Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-02-22 12:40 -0600
      Re: Shebang line on Windows? James Harris <james.harris.1@gmail.com> - 2013-02-22 14:53 -0800
        Re: Shebang line on Windows? MRAB <python@mrabarnett.plus.com> - 2013-02-22 23:21 +0000
        RE: Shebang line on Windows? "Sells, Fred" <fred.sells@adventistcare.org> - 2013-02-25 12:35 +0000
        Re: Shebang line on Windows? Dave Angel <davea@davea.name> - 2013-02-25 08:14 -0500
        Re: Shebang line on Windows? Chris Gonnerman <chris@gonnerman.org> - 2013-02-25 07:28 -0600
        Re: Shebang line on Windows? Chris Angelico <rosuav@gmail.com> - 2013-02-26 00:54 +1100
        Re: Shebang line on Windows? Michael Torrie <torriem@gmail.com> - 2013-02-25 10:18 -0700
          Re: Shebang line on Windows? Anssi Saari <as@sci.fi> - 2013-02-26 16:30 +0200
        Re: Shebang line on Windows? "D'Arcy J.M. Cain" <darcy@druid.net> - 2013-02-25 12:29 -0500
          Re: Shebang line on Windows? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-26 00:52 +0000
            Re: Shebang line on Windows? Michael Torrie <torriem@gmail.com> - 2013-02-25 19:08 -0700
            Re: Shebang line on Windows? Dave Angel <davea@davea.name> - 2013-02-25 21:23 -0500
            Re: Shebang line on Windows? MRAB <python@mrabarnett.plus.com> - 2013-02-26 03:08 +0000
            Re: Shebang line on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-25 22:44 -0500
        Re: Shebang line on Windows? David Robinow <drobinow@gmail.com> - 2013-02-25 13:19 -0500
        Re: Shebang line on Windows? Michael Torrie <torriem@gmail.com> - 2013-02-25 11:29 -0700
        Re: Shebang line on Windows? Michael Torrie <torriem@gmail.com> - 2013-02-25 11:33 -0700

#39602 — Shebang line on Windows?

FromWalter Hurry <walterhurry@lavabit.com>
Date2013-02-22 18:16 +0000
SubjectShebang line on Windows?
Message-ID<kg8cm0$flo$1@news.albasani.net>
I use FreeBSD or Linux, but my son is learning Python and is using 
Windows.

My question is this: Would it be good practice for him to put #!/usr/bin/
env python at the top of his scripts, so that if made executable on *nix 
they will be OK? As I understand it this will have no effect on Windows 
itself.

[toc] | [next] | [standalone]


#39604

FromDave Angel <davea@davea.name>
Date2013-02-22 13:40 -0500
Message-ID<mailman.2293.1361558458.2939.python-list@python.org>
In reply to#39602
On 02/22/2013 01:16 PM, Walter Hurry wrote:
> I use FreeBSD or Linux, but my son is learning Python and is using
> Windows.
>
> My question is this: Would it be good practice for him to put #!/usr/bin/
> env python at the top of his scripts, so that if made executable on *nix
> they will be OK? As I understand it this will have no effect on Windows
> itself.
>

In Python 3.3 under Windows, the shebang line is useful.  You run a 
program called py, which  examines the shebang, then loads the 
appropriate version.  I don't know much more, as I don't run Windows.

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#39605

FromZachary Ware <zachary.ware+pylist@gmail.com>
Date2013-02-22 12:40 -0600
Message-ID<mailman.2294.1361558483.2939.python-list@python.org>
In reply to#39602
On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhurry@lavabit.com> wrote:
> I use FreeBSD or Linux, but my son is learning Python and is using
> Windows.
>
> My question is this: Would it be good practice for him to put #!/usr/bin/
> env python at the top of his scripts, so that if made executable on *nix
> they will be OK? As I understand it this will have no effect on Windows
> itself.

Adding the shebang line on Windows would be excellent practice.  In
fact, Python 3.3 and later ships with the Python Launcher for Windows
[1] which is very effective at reading the shebang line and executing
the script with the proper Python installation.  It makes using Python
2.x and 3.x on the same Windows machine much less painful, as well as
not having to add anything to the PATH and being able to launch
whichever interpreter you want with a single command.

[1] http://docs.python.org/3/using/windows.html#python-launcher-for-windows

[toc] | [prev] | [next] | [standalone]


#39622

FromJames Harris <james.harris.1@gmail.com>
Date2013-02-22 14:53 -0800
Message-ID<b94bb7c4-14c2-4783-b13d-8a77e8dd6f32@r8g2000vbj.googlegroups.com>
In reply to#39605
On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl...@gmail.com>
wrote:

> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhu...@lavabit.com> wrote:

> > I use FreeBSD or Linux, but my son is learning Python and is using
> > Windows.
>
> > My question is this: Would it be good practice for him to put #!/usr/bin/
> > env python at the top of his scripts, so that if made executable on *nix
> > they will be OK? As I understand it this will have no effect on Windows
> > itself.
>
> Adding the shebang line on Windows would be excellent practice.

A word of warning unless this has since been resolved: Whenever I have
tried adding the shebang line on Windows and running it on Unix the
latter has complained about the carriage return at the end of the
line. This means that Unix does not work when invoked as follows.
(And, yes, the file has had chmod +x applied.)

  ./program.py

It is, of course, OK when run as

  python program.py

but that removes some of the benefit of the shebang line.

James

[toc] | [prev] | [next] | [standalone]


#39623

FromMRAB <python@mrabarnett.plus.com>
Date2013-02-22 23:21 +0000
Message-ID<mailman.2310.1361575278.2939.python-list@python.org>
In reply to#39622
On 2013-02-22 22:53, James Harris wrote:
> On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl...@gmail.com>
> wrote:
>
>> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhu...@lavabit.com> wrote:
>
>> > I use FreeBSD or Linux, but my son is learning Python and is using
>> > Windows.
>>
>> > My question is this: Would it be good practice for him to put #!/usr/bin/
>> > env python at the top of his scripts, so that if made executable on *nix
>> > they will be OK? As I understand it this will have no effect on Windows
>> > itself.
>>
>> Adding the shebang line on Windows would be excellent practice.
>
> A word of warning unless this has since been resolved: Whenever I have
> tried adding the shebang line on Windows and running it on Unix the
> latter has complained about the carriage return at the end of the
> line. This means that Unix does not work when invoked as follows.
> (And, yes, the file has had chmod +x applied.)
>
>    ./program.py
>
> It is, of course, OK when run as
>
>    python program.py
>
> but that removes some of the benefit of the shebang line.
>
Just use Unix line endings. Python will accept them, and any decent editor
on Windows will accept them. (Notepad doesn't.)

[toc] | [prev] | [next] | [standalone]


#39888

From"Sells, Fred" <fred.sells@adventistcare.org>
Date2013-02-25 12:35 +0000
Message-ID<mailman.2501.1361795789.2939.python-list@python.org>
In reply to#39622
When moving from windows to unix you need to run "dos2unix"   on any programs that use shebang (at least with python 2.6)   that is installed on some platforms but must be installed on others like CentOs but it is in their repository.

-----Original Message-----
From: Python-list [mailto:python-list-bounces+frsells=adventistcare.org@python.org] On Behalf Of James Harris
Sent: Friday, February 22, 2013 5:53 PM
To: python-list@python.org
Subject: Re: Shebang line on Windows?

On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl...@gmail.com>
wrote:

> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhu...@lavabit.com> wrote:

> > I use FreeBSD or Linux, but my son is learning Python and is using 
> > Windows.
>
> > My question is this: Would it be good practice for him to put 
> > #!/usr/bin/ env python at the top of his scripts, so that if made 
> > executable on *nix they will be OK? As I understand it this will 
> > have no effect on Windows itself.
>
> Adding the shebang line on Windows would be excellent practice.

A word of warning unless this has since been resolved: Whenever I have tried adding the shebang line on Windows and running it on Unix the latter has complained about the carriage return at the end of the line. This means that Unix does not work when invoked as follows.
(And, yes, the file has had chmod +x applied.)

  ./program.py

It is, of course, OK when run as

  python program.py

but that removes some of the benefit of the shebang line.

James
--
http://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#39890

FromDave Angel <davea@davea.name>
Date2013-02-25 08:14 -0500
Message-ID<mailman.2503.1361798104.2939.python-list@python.org>
In reply to#39622

> -----Original Message-----
> From: Python-list [mailto:python-list-bounces+frsells=adventistcare.org@python.org] On Behalf Of James Harris
> Sent: Friday, February 22, 2013 5:53 PM
> To: python-list@python.org
> Subject: Re: Shebang line on Windows?
>
> On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl...@gmail.com>
>
> A word of warning unless this has since been resolved: Whenever I have tried adding the shebang line on Windows and running it on Unix the latter has complained about the carriage return at the end of the line. This means that Unix does not work when invoked as follows.
> (And, yes, the file has had chmod +x applied.)
>
>    ./program.py
>
> It is, of course, OK when run as
>
>    python program.py
>
> but that removes some of the benefit of the shebang line.
>
> James
> --
> http://mail.python.org/mailman/listinfo/python-list
>

(Fixing top-posted response, so it comes after the part it is quoting)
On 02/25/2013 07:35 AM, Sells, Fred wrote:
 > When moving from windows to unix you need to run "dos2unix"   on any
 > programs that use shebang (at least with python 2.6)   that is
 > installed on some platforms but must be installed on others like
 > CentOs but it is in their repository.
 >

It's not Python that needs dos2unix, it's bash or equivalent.  For some 
reason, bash shebang processing still isn't tolerant of a trailing cr on 
the line. Python doesn't care.

If someone is maintaining sources that need to run on both, it's easier 
to maintain them using Unix-style newlines.  All it usually requires is 
a decent Windows text editor that honors the existing newline 
convention.  Or better that can be configured to always use simple 
newlines at end of each line.


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#39892

FromChris Gonnerman <chris@gonnerman.org>
Date2013-02-25 07:28 -0600
Message-ID<mailman.2505.1361799399.2939.python-list@python.org>
In reply to#39622

[Multipart message — attachments visible in raw view] — view raw

On 02/25/2013 06:35 AM, Sells, Fred wrote:
> When moving from windows to unix you need to run "dos2unix"   on any programs that use shebang (at least with python 2.6)   that is installed on some platforms but must be installed on others like CentOs but it is in their repository.
Or edit it in Vim and do

:se ff=unix

and then save it.

dos2unix is handy if you don't plan to edit the file for any other 
reason.  I'm assuming other editors provide similar features, but I've 
been a vi/vim user FOREVER.

Or, borrowed from a Stack Overflow thread here: 
http://stackoverflow.com/questions/800030/remove-carriage-return-in-unix

|sed 's/\r\n$/\n/' mymodule.py > mymodule-unix.py|


>
> -----Original Message-----
> From: Python-list [mailto:python-list-bounces+frsells=adventistcare.org@python.org] On Behalf Of James Harris
> Sent: Friday, February 22, 2013 5:53 PM
> To: python-list@python.org
> Subject: [Python] Re: Shebang line on Windows?
>
> On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl...@gmail.com>
> wrote:
>
>> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhu...@lavabit.com> wrote:
>>> I use FreeBSD or Linux, but my son is learning Python and is using
>>> Windows.
>>> My question is this: Would it be good practice for him to put
>>> #!/usr/bin/ env python at the top of his scripts, so that if made
>>> executable on *nix they will be OK? As I understand it this will
>>> have no effect on Windows itself.
>> Adding the shebang line on Windows would be excellent practice.
> A word of warning unless this has since been resolved: Whenever I have tried adding the shebang line on Windows and running it on Unix the latter has complained about the carriage return at the end of the line. This means that Unix does not work when invoked as follows.
> (And, yes, the file has had chmod +x applied.)
>
>    ./program.py
>
> It is, of course, OK when run as
>
>    python program.py
>
> but that removes some of the benefit of the shebang line.
>
> James
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#39893

FromChris Angelico <rosuav@gmail.com>
Date2013-02-26 00:54 +1100
Message-ID<mailman.2506.1361800471.2939.python-list@python.org>
In reply to#39622
On Tue, Feb 26, 2013 at 12:28 AM, Chris Gonnerman <chris@gonnerman.org> wrote:
> On 02/25/2013 06:35 AM, Sells, Fred wrote:
>
>> When moving from windows to unix you need to run "dos2unix"   on any
>> programs that use shebang (at least with python 2.6)   that is installed on
>> some platforms but must be installed on others like CentOs but it is in
>> their repository.
>
> Or edit it in Vim and do
>
> :se ff=unix
>
> and then save it.

Or manage your files in git and set the core.autocrlf option to always
commit with Unix newlines (and you can optionally check files out with
DOS newlines, if you wish). Strongly recommended for cross-platform
work, as it "just happens" - no need to explicitly convert the file.

ChrisA

[toc] | [prev] | [next] | [standalone]


#39898

FromMichael Torrie <torriem@gmail.com>
Date2013-02-25 10:18 -0700
Message-ID<mailman.2510.1361812739.2939.python-list@python.org>
In reply to#39622
On 02/25/2013 06:14 AM, Dave Angel wrote:
> It's not Python that needs dos2unix, it's bash or equivalent.  For some 
> reason, bash shebang processing still isn't tolerant of a trailing cr on 
> the line. Python doesn't care.

Actually, the shell isn't involved in parsing the shebang line at all.
That's actually done in the kernel by the program loader.  So it's the
kernel that has a problem with it; wonder if Linus would accept a patch
to ignore the tailing CR?

[toc] | [prev] | [next] | [standalone]


#39953

FromAnssi Saari <as@sci.fi>
Date2013-02-26 16:30 +0200
Message-ID<vg3hakzqh9n.fsf@coffee.modeemi.fi>
In reply to#39898
Michael Torrie <torriem@gmail.com> writes:

> Actually, the shell isn't involved in parsing the shebang line at all.
> That's actually done in the kernel by the program loader.  So it's the
> kernel that has a problem with it; wonder if Linus would accept a patch
> to ignore the tailing CR?

Worth a try in my opinion. There's some historical information about the
shebang at http://www.in-ulm.de/~mascheck/various/shebang/ There's a
table which says Linux since 2.4.0 removes trailing whitespace from the
shebang line. I guess Linux doesn't count CR as whitespace in this
context.

[toc] | [prev] | [next] | [standalone]


#39900

From"D'Arcy J.M. Cain" <darcy@druid.net>
Date2013-02-25 12:29 -0500
Message-ID<mailman.2512.1361814005.2939.python-list@python.org>
In reply to#39622
On Mon, 25 Feb 2013 10:18:44 -0700
Michael Torrie <torriem@gmail.com> wrote:
> On 02/25/2013 06:14 AM, Dave Angel wrote:
> > It's not Python that needs dos2unix, it's bash or equivalent.  For
> > some reason, bash shebang processing still isn't tolerant of a
> > trailing cr on the line. Python doesn't care.
> 
> Actually, the shell isn't involved in parsing the shebang line at all.
> That's actually done in the kernel by the program loader.  So it's the
> kernel that has a problem with it; wonder if Linus would accept a
> patch to ignore the tailing CR?

So much the wrong solution.  First of all, I don't think that Linus is
on the bash development team so he can't help there.  Also, bash is not
the only shell in the world.  And, Linux is not the only operating
system in the world.  There are still a lot of Unix systems (the system
that Linux is a clone of) out there.  FreeBSD, NetBSD, Solaris, Mac
OSX, etc.  You can't expect all of them to bend over backwards for
every Windows wart out there.

I don't run Windows myself so I can't test it but doesn't Python on
Windows work fine with Unix style EOL?  So why not strip out the CR and
run the same file everywhere?

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
IM: darcy@Vex.Net, VOIP: sip:darcy@Vex.Net

[toc] | [prev] | [next] | [standalone]


#39918

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-02-26 00:52 +0000
Message-ID<512c0749$0$29998$c3e8da3$5496439d@news.astraweb.com>
In reply to#39900
On Mon, 25 Feb 2013 12:29:58 -0500, D'Arcy J.M. Cain wrote:

> On Mon, 25 Feb 2013 10:18:44 -0700
> Michael Torrie <torriem@gmail.com> wrote:
>> On 02/25/2013 06:14 AM, Dave Angel wrote:
>> > It's not Python that needs dos2unix, it's bash or equivalent.  For
>> > some reason, bash shebang processing still isn't tolerant of a
>> > trailing cr on the line. Python doesn't care.
>> 
>> Actually, the shell isn't involved in parsing the shebang line at all.
>> That's actually done in the kernel by the program loader.  So it's the
>> kernel that has a problem with it; wonder if Linus would accept a patch
>> to ignore the tailing CR?
> 
> So much the wrong solution.  First of all, I don't think that Linus is
> on the bash development team so he can't help there.

/facepalm

Perhaps you forgot to read Michael's comment before criticising it?

The bash dev team is irrelevant, because this is not a bash problem. It 
is the kernel, not bash, that reads the shebang line. So yes, Linus 
Torvalds could fix this problem if he chose.


> Also, bash is not
> the only shell in the world.  And, Linux is not the only operating
> system in the world.  There are still a lot of Unix systems (the system
> that Linux is a clone of) out there.  FreeBSD, NetBSD, Solaris, Mac OSX,
> etc.  You can't expect all of them to bend over backwards for every
> Windows wart out there.

Nobody is asking anyone to support "every Windows wart out there". 
Windows-style line separators are not a wart, it is a convention used by 
many, many tools, operating systems, data formats (e.g. email), etc. It 
is an old, old convention, going back to teletype days and so predating 
not just Windows but also Unix. So in fact it is *Unix* that broke the 
convention, and Unix line separators which is the "wart" (or at least a 
regression).


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#39922

FromMichael Torrie <torriem@gmail.com>
Date2013-02-25 19:08 -0700
Message-ID<mailman.2527.1361844501.2939.python-list@python.org>
In reply to#39918
On 02/25/2013 05:52 PM, Steven D'Aprano wrote:
> Nobody is asking anyone to support "every Windows wart out there". 
> Windows-style line separators are not a wart, it is a convention used by 
> many, many tools, operating systems, data formats (e.g. email), etc. It 
> is an old, old convention, going back to teletype days and so predating 
> not just Windows but also Unix. So in fact it is *Unix* that broke the 
> convention, and Unix line separators which is the "wart" (or at least a 
> regression).

That's really interesting.  I didn't know that before.  It does make
sense.  As much as I love unix, it really originated as a hack in many
senses.  With that in mind I think Linux should allow a trailing CR in
the shebang line, even if other unix OS's don't.  Of course it's a minor
thing, and there are ways of dealing with it.

This is a reminder to me how much we Linux users look at Windows as a
quaint anomaly with it's apparently backwards ways of doing things (like
backslash directory separators, like CP/M did), but forget it is still
the dominant platform out there for general purpose computing.  So it
really could be argued that Linux indeed is the backward OS when it
comes to these kind of incompatibilities (though I still think I like it
better!)

[toc] | [prev] | [next] | [standalone]


#39923

FromDave Angel <davea@davea.name>
Date2013-02-25 21:23 -0500
Message-ID<mailman.2528.1361845466.2939.python-list@python.org>
In reply to#39918
On 02/25/2013 09:08 PM, Michael Torrie wrote:
>   <snip>
> This is a reminder to me how much we Linux users look at Windows as a
> quaint anomaly with it's apparently backwards ways of doing things (like
> backslash directory separators, like CP/M did),

Actually the reason MSDOS used backslash was because it had already used 
the forward slash for a switch-character.  Then for version 2, with hard 
disks being supported for the first time, they used the backslash 
instead.  At the time I talked them into supporting a "switchchar" call 
to change to using the dash for switch character, and slash for 
subdirectories.

But the idea was never publicized, so it never caught on.  And future 
versions of utilities generally paid no attention to the value of 
switchchar.

By the time Windows split off from MSDOS (NT 3.1), the support in the OS 
for both slash and backslash was well established.  But the utilities 
never grew up.

Yes, using the slash as a switch-character was inherited from CP/M, 
through QDOS, then MSDOS.


On some of the old teletypes, if the data was coming in fast enough, you 
could see the first character of the next line printed before the typing 
element reached the left margin.  So newline was then spelled CR/LF/NULL 
  or even  CR/LF/NULL/NULL

Buffering?  What's that?

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#39924

FromMRAB <python@mrabarnett.plus.com>
Date2013-02-26 03:08 +0000
Message-ID<mailman.2529.1361848114.2939.python-list@python.org>
In reply to#39918
On 2013-02-26 02:08, Michael Torrie wrote:
> On 02/25/2013 05:52 PM, Steven D'Aprano wrote:
>> Nobody is asking anyone to support "every Windows wart out there".
>> Windows-style line separators are not a wart, it is a convention used by
>> many, many tools, operating systems, data formats (e.g. email), etc. It
>> is an old, old convention, going back to teletype days and so predating
>> not just Windows but also Unix. So in fact it is *Unix* that broke the
>> convention, and Unix line separators which is the "wart" (or at least a
>> regression).
>
> That's really interesting.  I didn't know that before.  It does make
> sense.  As much as I love unix, it really originated as a hack in many
> senses.  With that in mind I think Linux should allow a trailing CR in
> the shebang line, even if other unix OS's don't.  Of course it's a minor
> thing, and there are ways of dealing with it.
>
> This is a reminder to me how much we Linux users look at Windows as a
> quaint anomaly with it's apparently backwards ways of doing things (like
> backslash directory separators, like CP/M did), but forget it is still
> the dominant platform out there for general purpose computing.  So it
> really could be argued that Linux indeed is the backward OS when it
> comes to these kind of incompatibilities (though I still think I like it
> better!)
>
That reminds me of the time I was making PPD (PostScript Printer
Description) files. They worked on both Windows and MacOS.

Then Apple released MacOS X, which complained when they were installed.

It turned out that MacOS X didn't like the line endings. It insisted on
CR only, despite the fact that the PPD specification said that the line
endings could be CR, LF, or CR/LF, and that they had followed the
specification previously!

[toc] | [prev] | [next] | [standalone]


#39926

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-02-25 22:44 -0500
Message-ID<mailman.2530.1361850304.2939.python-list@python.org>
In reply to#39918
On Mon, 25 Feb 2013 19:08:08 -0700, Michael Torrie <torriem@gmail.com>
declaimed the following in gmane.comp.python.general:


> That's really interesting.  I didn't know that before.  It does make
> sense.  As much as I love unix, it really originated as a hack in many
> senses.  With that in mind I think Linux should allow a trailing CR in
> the shebang line, even if other unix OS's don't.  Of course it's a minor
> thing, and there are ways of dealing with it.
> 
	Even the <cr><lf> ORDER goes back to teletypes. It took more time
for the <cr> to complete than the <lf> so putting it first allowed the
print head to continue moving left when the <lf> rotated the platen
upward (and on a particularly slow system, with paper tape, one could
use <cr><lf><rubout> to give more time).
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#39902

FromDavid Robinow <drobinow@gmail.com>
Date2013-02-25 13:19 -0500
Message-ID<mailman.2514.1361816351.2939.python-list@python.org>
In reply to#39622
On Mon, Feb 25, 2013 at 12:29 PM, D'Arcy J.M. Cain <darcy@druid.net> wrote:
> ...
> I don't run Windows myself so I can't test it but doesn't Python on
> Windows work fine with Unix style EOL?  So why not strip out the CR and
> run the same file everywhere?
 That's the ideal solution, but so many Windows tools default to text
mode that it's easy to create the wrong type file, especially for
beginners who are moving there code to Linux for the first time.  I've
done it myself, even though I should no better by now.
 In addition, the error message is rather obscure (if I remember right
- I'm not near my Ubuntu at the moment and Cygwin handles this fine,
as it should)
 I'm afraid this problem won't go away. People are just going to have
to learn from experience.

[toc] | [prev] | [next] | [standalone]


#39903

FromMichael Torrie <torriem@gmail.com>
Date2013-02-25 11:29 -0700
Message-ID<mailman.2515.1361817007.2939.python-list@python.org>
In reply to#39622
On 02/25/2013 10:29 AM, D'Arcy J.M. Cain wrote:
> So much the wrong solution.  First of all, I don't think that Linus is
> on the bash development team so he can't help there.  Also, bash is not
> the only shell in the world.  

Ooops you didn't read what I said.  The shebang parsing is not done by
bash.  It's done by the kernel.  So it has nothing to do with bash or
any shell for that matter.

> And, Linux is not the only operating
> system in the world.  There are still a lot of Unix systems (the system
> that Linux is a clone of) out there.  FreeBSD, NetBSD, Solaris, Mac
> OSX, etc.  You can't expect all of them to bend over backwards for
> every Windows wart out there.

Yup.  This is true.  My suggestion was tongue in cheek.

[toc] | [prev] | [next] | [standalone]


#39904

FromMichael Torrie <torriem@gmail.com>
Date2013-02-25 11:33 -0700
Message-ID<mailman.2516.1361817241.2939.python-list@python.org>
In reply to#39622
On 02/25/2013 10:29 AM, D'Arcy J.M. Cain wrote:
> I don't run Windows myself so I can't test it but doesn't Python on
> Windows work fine with Unix style EOL?  So why not strip out the CR and
> run the same file everywhere?

As has been said on this thread, python is perfectly happy on windows
with the Unix-style EOL.  And if you use a good programmer's editor, it
will happily keep unix-style line endings.  Use a crappier,
windows-centric editor, and you'll see the CR's creeping back in.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web