public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-12 15:22 Chris January
  0 siblings, 0 replies; 36+ messages in thread
From: Chris January @ 2002-02-12 15:22 UTC (permalink / raw)
  To: cygwin

> > > I use different computers where Perl is installed different
> > > places, so I can't hardcode the location of perl in the shebang
> > > line.  Thus, I use env, which works great on all UNIXes I work on,
> > > for instance
> > >
> > >     #!/usr/bin/env perl -w
> > >
> > >     print "This is Perl version $]\n";
> > >
> > > but on Cygwin I get
> > >
> > >     /usr/bin/env: perl -w: No such file or directory
> > >
> > > why does Cygwin look for the file "perl -w".  No UNIX I have
> > > worked on would parse the shebang line that way.
> > Linux parses things this way too. I don't know what "UNIX"'s this works
> on.
> > (Sun, HP?)
More specifically it's a quoting issue.
Try:
/usr/bin/env perl -w
on the command line and compare with
"/usr/bin/env perl -w"

Regards
Chris

 
> 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-22  5:26 pjacklam
  0 siblings, 0 replies; 36+ messages in thread
From: pjacklam @ 2002-02-22  5:26 UTC (permalink / raw)
  To: cygwin

> Create a wrapper script, e.g. '/usr/local/bin/perl -w', with
> contents
>
>         #!/bin/sh
>         perl -w $*

Firstly, I would need to do that on every computer I might
run Perl on, which in itself is harly possible.  At the
very least it is rather impractical.

Secondly, I run Perl with many different combinations of
options, like "perl -w", "perl -wn", "perl -0777 -wn", etc.
which makes that approach even far less feasible.

By the way, you did mean "$@" and not $*, didn't you? :-)

Peter

-- 
Peter J. Acklam - pjacklam@online.no - http://home.online.no/~pjacklam


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-22  1:27 pjacklam
  2002-02-22  4:34 ` Michael Schaap
  0 siblings, 1 reply; 36+ messages in thread
From: pjacklam @ 2002-02-22  1:27 UTC (permalink / raw)
  To: cygwin

hammond@csc.albany.edu (William F. Hammond) writes:

> I don't understand why you want to use /usr/bin/env
> under Cygwin.

The reason is portability.  I have written hundreds of
Perl utilities which I find extremely useful and I
want them to run smoothly both on UNIX and cygwin.
I really hesitate to maintain one set of utilities for
cygwin, one for Solaris, one for HP-UX, etc.

> Not everything that makes sense under *ix makes sense
> for Cygwin.

I know, but cygwin respects shebang lines (e.g., a text
file in the path starting with the line "#!/bin/gawk"
will really be run by gawk), so I'm sure there is a way
to get this working right.  I just haven't found it yet.

> Presumably one runs Cygwin because one does not want
> to run Linux so that one can have simultaneous single
> platform access to Win* things and Gnu things familiar
> in *ix contexts.

Yep.

> That said, doesn't it then make sense to use a straight
> Win* build for perl so that perl can be used in Win*
> mode?

I have tried, and I found out that a Win* build of Perl
doesn't integrate well with cygwin.

> Granted that -- and granted the desire to build
> environment outside of the Perl script itself -- one
> may use either a bat file or an sh script, as appropriate
> for the calling context, to create the needed environment.

True, that works, I have tried, but then I need a whole
set of bat files and sh files in addition to the original
Perl scripts and that's what I am trying to avoid.  :-)

Thanks for your input!

Peter


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* RE: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-13 14:13 Heribert Dahms
  0 siblings, 0 replies; 36+ messages in thread
From: Heribert Dahms @ 2002-02-13 14:13 UTC (permalink / raw)
  To: 'Lassi A. Tuura', cygwin; +Cc: 'pjacklam@online.no'

Hi,

another generic way would be a shell wrapper named "perl -w"
somewhere in the PATH e.g. /usr/local/bin,
so Peter wouldn't need to change a lot of scripts.


Bye, Heribert (heribert_dahms@icon-scm.com)

> -----Original Message-----
> From:	Lassi A. Tuura [SMTP:lassi.tuura@cern.ch]
> Sent:	Wednesday, February 13, 2002 20:15
> To:	cygwin@cygwin.com
> Subject:	Re: /usr/bin/env - Incorrect parsing of #! line?
> 
> > Find some other way to accomplish what you need to do.
> 
> #!/usr/bin/env perl
> BEGIN { $^W = 1; }
> 
> $foo = 0;
> 
> //lat
> -- 
> No matter how hard you try, you can't make a baby in much less than
> 9 months.  Trying to speed this up *might* make it slower, but it
> won't make it happen any quicker.
> 	--RFC1925, "The Twelve Networking Truths"
> 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-13  6:53 Chet Ramey
  2002-02-13 10:37 ` Christopher Faylor
  0 siblings, 1 reply; 36+ messages in thread
From: Chet Ramey @ 2002-02-13  6:53 UTC (permalink / raw)
  To: dgluss; +Cc: pjacklam, cygwin, chet

> The problem looks to be that bash "helps out" the system
> by executing scripts beginning with #!.  In the source for
> bash, look in execute_cmd.c, line 3369.  Only one argument
> is allowed.  So e.g. #!/usr/bin/env perl -w becomes
> "/usr/bin/env" "perl -w"
> If I make a patch for this, should it go to the cygwin list?
> Should it just go to gnu.bash.bug and leave it at that?

Only if the kernel doesn't do it, as discovered by configure.
Virtually all Unices understand that executable format in the
kernel.  Cygwin does, too.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* RE: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-13  6:50 Chet Ramey
  2002-02-13  7:16 ` Gerald S. Williams
  0 siblings, 1 reply; 36+ messages in thread
From: Chet Ramey @ 2002-02-13  6:50 UTC (permalink / raw)
  To: gsw; +Cc: cygwin, dgluss, pjacklam, chet

> I think DG's and PJA's original assessment was correct and
> BASH should be modified. Support for cross-platform scripts
> is important, and the #!/bin/env trick is used frequently.

How is changing bash going to do anything?  The kernel takes
care of executing files with a `#!' magic number.  I presume
that the cygwin dll handles this.

There is an incompatibility between the linux kernel and other
Unices in the way they parse arguments after the interpreter
name, but that's not really bash's business.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-12 17:47 David Gluss
  2002-02-12 17:54 ` Christopher Faylor
  0 siblings, 1 reply; 36+ messages in thread
From: David Gluss @ 2002-02-12 17:47 UTC (permalink / raw)
  To: Peter J. Acklam; +Cc: cygwin

The problem looks to be that bash "helps out" the system
by executing scripts beginning with #!.  In the source for
bash, look in execute_cmd.c, line 3369.  Only one argument
is allowed.  So e.g. #!/usr/bin/env perl -w becomes
"/usr/bin/env" "perl -w"
If I make a patch for this, should it go to the cygwin list?
Should it just go to gnu.bash.bug and leave it at that?
DG 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread
* /usr/bin/env - Incorrect parsing of #! line?
@ 2002-02-12 10:38 Peter J. Acklam
  2002-02-12 10:53 ` Christopher Faylor
                   ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Peter J. Acklam @ 2002-02-12 10:38 UTC (permalink / raw)
  To: cygwin

I use different computers where Perl is installed different
places, so I can't hardcode the location of perl in the shebang
line.  Thus, I use env, which works great on all UNIXes I work on,
for instance

    #!/usr/bin/env perl -w

    print "This is Perl version $]\n";

but on Cygwin I get

    /usr/bin/env: perl -w: No such file or directory

why does Cygwin look for the file "perl -w".  No UNIX I have
worked on would parse the shebang line that way.

Peter

-- 
People say I'm indifferent, but I don't care.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2002-02-22 13:21 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-12 15:22 /usr/bin/env - Incorrect parsing of #! line? Chris January
  -- strict thread matches above, loose matches on Subject: below --
2002-02-22  5:26 pjacklam
2002-02-22  1:27 pjacklam
2002-02-22  4:34 ` Michael Schaap
2002-02-13 14:13 Heribert Dahms
2002-02-13  6:53 Chet Ramey
2002-02-13 10:37 ` Christopher Faylor
2002-02-13 11:14   ` Lassi A. Tuura
2002-02-13  6:50 Chet Ramey
2002-02-13  7:16 ` Gerald S. Williams
2002-02-12 17:47 David Gluss
2002-02-12 17:54 ` Christopher Faylor
2002-02-12 19:10   ` David Gluss
2002-02-13  6:26     ` Gerald S. Williams
2002-02-13  6:38       ` Michael Schaap
2002-02-13  6:39       ` Robert Praetorius
2002-02-13  6:52       ` Benoit Rochefort
2002-02-14 11:55       ` Gerald S. Williams
2002-02-20 12:57   ` Peter J. Acklam
2002-02-20 13:37     ` Larry Hall (RFK Partners, Inc)
2002-02-21 12:47       ` Peter J. Acklam
2002-02-21 13:04         ` Peter J. Acklam
2002-02-21 19:10         ` William F. Hammond
2002-02-20 21:33     ` Christopher Faylor
2002-02-21 13:23       ` Peter J. Acklam
2002-02-12 10:38 Peter J. Acklam
2002-02-12 10:53 ` Christopher Faylor
2002-02-12 12:16   ` Peter J. Acklam
2002-02-12 14:25     ` Charles Wilson
2002-02-12 14:59       ` David Gluss
2002-02-20 13:03       ` Peter J. Acklam
2002-02-12 11:56 ` David Gluss
2002-02-12 12:17   ` Peter J. Acklam
2002-02-12 13:56     ` David Gluss
2002-02-12 14:57 ` Chris January
2002-02-20 12:57   ` Peter J. Acklam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).