home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: More #! stuff
- Message-ID: <1992Aug25.221932.11112@netlabs.com>
- Date: 25 Aug 92 22:19:32 GMT
- References: <BtCEuC.1K4@world.std.com> <1992Aug24.185939.19357@netlabs.com> <BtI899.KJ2@world.std.com>
- Sender: news@netlabs.com
- Distribution: usa
- Organization: NetLabs, Inc.
- Lines: 64
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <BtI899.KJ2@world.std.com> dsb@world.std.com (David Boyce) writes:
- : In article <1992Aug24.185939.19357@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
- : >Similar schemes have been proposed, but the difficulty with it (aside
- : >from the fact that not all machines have /bin/env) is that a #! line
- : >typically allows you only one argument, and you've already used it up
- : >specifying perl. It's like having to use up your three wishes to get
- : >the genie out of the bottle.
- : >
- : >Larry
- :
- : When I write shell code, I always use (and recommend)
- :
- : #!/bin/sh
- : set -e
- :
- : rather than
- :
- : #!/bin/sh -e
- :
- : because if you happened to run the script via "sh script",
- : the second way would lose the flag, which could be dangerous in
- : the case of -e. Does perl support anything like the
- : set command? I can't find it, but I, at least, would
- : like to have it for the reason cited above, as well as to
- : obviate the second problem you mentioned.
-
- Most of the options that make sense to set internally can be set
- via the corresponding magical variable, e.g.
-
- $^I = ".bak";
-
- is the same as
-
- -i.bak
-
- (presuming you set it before you start using <>).
-
- Many switches don't make sense once you've started compiling the
- script, however. In particular, -p, -n, and -a. And yes, you
- do lose these if you invoke perl directly. I suppose I could make
- perl pick those up from the #! line anyway... Hmmm...
-
- : As for not every machine having /bin/env; this is true,
- : but I think every *ix machine has env, and most of them in
- : /bin. I didn't mean that it's the universal solution; just
- : that there are probably many local-area networks in the world that
- : can count on /bin/env existing across the board. I mean,
- : when the alternative is
- :
- : #!/c/cad1/cad/perl/bin/perl
- :
- : as it is in one company that I'm working for, I think using env
- : is more portable!
-
- Surely. (Presuming of course, that /c/cad1/cad/perl/bin is in your
- PATH.) But the BSD machines I used to use didn't have /bin/env. Now,
- you may not consider them to be *ix, but it would seem that AT&T still
- does...
-
- Certainly, it's easy enough to write env in C if you don't have it.
- (But, of course, if you have authority to install /bin/env, you can also
- ln -s /c/cad1/cad/perl/bin/perl /usr/bin/perl.)
-
- Larry
-