delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/04/11:18:25

Date: Sun, 04 Mar 2001 18:18:24 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Daniel Barker <sokal AT holyrood DOT ed DOT ac DOT uk>
Message-Id: <2110-Sun04Mar2001181824+0200-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
CC: djgpp AT delorie DOT com
In-reply-to: <Pine.SOL.4.21.0103041457030.10320-100000@holyrood.ed.ac.uk>
(message from Daniel Barker on Sun, 4 Mar 2001 14:58:15 +0000 (GMT))
Subject: Re: Penalty for immature language (PERL/BASH)
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1010304080956 DOT 12520D-100000 AT is> <Pine DOT SOL DOT 4 DOT 21 DOT 0103041457030 DOT 10320-100000 AT holyrood DOT ed DOT ac DOT uk>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Newsgroups: comp.os.msdos.djgpp
> Date: Sun, 4 Mar 2001 14:58:15 +0000 (GMT)
> From: Daniel Barker <sokal AT holyrood DOT ed DOT ac DOT uk>
> 
> I still have a small question. Neither BASH nor COMMAND.COM will run
> poo.pl if I just enter the command poo (without extension). I expect
> this. In BASH, I do not have . (current directory) in my PATH, and
> COMMAND.COM does not regard .pl files as executable. So why is PERL even
> trying to arrange execution of the file poo.pl?

I don't know Perl well enough to answer that.  My guess would be that
Perl simply calls the library function `system' (or maybe `popen',
which calls `system' internally) asking it to run `poo'.  `system'
looks and finds `poo.pl', but support for .pl scripts assumes that the
first line of the script says what program should be invoked to run
this script; `poo.pl' violates that assumption.

I don't know what `poo.pl' was supposed to do, or how did you arrive
at a program which ended up invoking it, but it sounds like a result
of a rare coincidence together with a couple of subtle and
hard-to-solve problems which have to do with running arbitrary
programs on DOS/Windows.  On balance, Perl should have been more
cautious; it could, for example, check if the file is executable
before invoking it.

The next version of the DJGPP library changes the way `system' handles
such files, because the current behavior is a bit unsafe, as you
learned from this example.  The modified `system' will not find
`poo.pl' unless you actually mention the .pl extension.  But I imagine
even the new code will crash if you say `poo.pl` in a Perl program,
and `poo.pl' doesn't have the "#!/usr/local/perl" on its first line.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019