tneff@bfmny0.BFM.COM (Tom Neff) (09/14/90)
In article <1990Sep13.183429.17002@uvaarpa.Virginia.EDU> worley@compass.com writes: >I've written the following script ... ... >do "/compass/c/worley/perl-3.0/lib/getopt.pl"; >do "/compass/c/worley/perl-3.0/sys/syscall.h"; Come on people -- is it really necessary to leave this kind of line in a Perl script being distributed to the world? How about exercising a little reasonability when you post, and eliminating the weird custom directories instead of making thousands of individual users do it? This also applies to BSD-style interpreter lines like #! /u9/hawhaw/garygilmore/pub/special/jetson/bin/perl and so forth. I don't mean to pick on Doug in particular, but this happens a lot. At ease -- smoke em if you got em. :-) -- Television is a medium because anything /+\ Tom Neff well done is rare. -- Fred Allen \-/ tneff@bfmny0.BFM.COM
merlyn@iwarp.intel.com (Randal Schwartz) (09/15/90)
In article <15856@bfmny0.BFM.COM>, tneff@bfmny0 (Tom Neff) writes: | In article <1990Sep13.183429.17002@uvaarpa.Virginia.EDU> worley@compass.com writes: | >I've written the following script ... | ... | >do "/compass/c/worley/perl-3.0/lib/getopt.pl"; | | >do "/compass/c/worley/perl-3.0/sys/syscall.h"; | | Come on people -- is it really necessary to leave this kind of line in a | Perl script being distributed to the world? How about exercising a | little reasonability when you post, and eliminating the weird custom | directories instead of making thousands of individual users do it? And replace them with *what*? *Your* custom directory? How will I know what that is? At least with a name like /compass/c/worley/blah/blah/blah, I know enough to think "hey, maybe he's *not* talking about something from the distribution there". require "/local/merlyn/bin/perl/japh.pl"; &japh(17); # :-) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (09/15/90)
Such directory names (and any other configuration options) should be brought to the front of the script for easy modificatino. In the special case of the #! lines, you can use the fixin program to fix incoming scripts: #!/usr/bin/perl 'di'; 'ig00'; # # $Header: fixin,v 1.1 90/08/12 00:15:56 lwall Locked $ # # $Log: fixin,v $ # Revision 1.1 90/08/12 00:15:56 lwall # Initial revision # # fixin - fix interpreter lines on incoming scripts $does_shbang = 1; # Does kernel recognize #! hack? $verbose = 1; # Default to verbose @absdirs = reverse grep(m!^/!, split(/:/, $ENV{'PATH'}, 999)); if ($ARGV[0] eq '-s') { shift; $verbose = 0; } die "Usage: fixin [-s] [files]\n" unless @ARGV || !-t; @ARGV = '-' unless @ARGV; FILE: foreach $filename (@ARGV) { open(IN, $filename) || ((warn "Can't open $filename\n"), next); $_ = <IN>; next FILE unless /^#!/; chop($cmd = $_); $cmd =~ s/^#! *//; ($cmd,$arg) = split(' ', $cmd, 2); $cmd =~ s!^.*/!!; $found = ''; foreach $dir (@absdirs) { if (-x "$dir/$cmd") { warn "Ignoring $found\n" if $verbose && $found; $found = "$dir/$cmd"; } } if ($found) { warn "Changing $filename to $found\n" if $verbose; if ($does_shbang) { $_ = "#!$found"; $_ .= ' ' . $arg if $arg ne ''; $_ .= "\n"; } else { $_ = <<EOF; : eval 'exec $found $arg -S \$0 \${1+"\$@"}' if \$running_under_some_shell; EOF } } else { warn "Can't find $cmd in PATH, leaving $filename unchanged\n" if $verbose; next FILE; } if ($filename eq '-') { select(STDOUT); } else { rename($filename, "$filename.bak") || ((warn "Can't modify $filename"), next FILE); open(OUT,">$filename") || die "Can't create new $filename: $!\n"; ($dev,$ino,$mode) = stat IN; $mode = 0644 unless $dev; chmod $mode, $filename; select(OUT); } print; while (<IN>) { print; } close IN; close OUT; } ############################################################################## # These next few lines are legal in both Perl and nroff. .00; # finish .ig 'di \" finish diversion--previous line must be blank .nr nl 0-1 \" fake up transition to first page again .nr % 0 \" start at page 1 '; __END__ ############# From here on it's a standard manual page ############ .TH FIXIN 1 "August 11, 1990" .AT 3 .SH NAME fixin \- fix incoming scripts to use reasonable #! line .SH SYNOPSIS .B fixin [-s] [files] .SH DESCRIPTION .I Fixin fixes the specified files so that the #! line at the beginning of the file reflects the actual location of the interpreter on this system. The files are modified in place, with a .bak backup. If no files are specified, acts as a filter. It searches your current path for files matching the last component of the current #! line and changes it to the first match. .PP The .B \-s switch makes fixin shutup about what it's doing. .SH ENVIRONMENT Uses absolute components of PATH to decide where to look for interpreters. .SH FILES None. .SH AUTHOR Larry Wall .SH "SEE ALSO" .SH DIAGNOSTICS Warns you if there is more than one interpeter by that name in PATH. .PP Warns you if there is no interpreter by that name in PATH. .SH BUGS Larry Wall lwall@jpl-devvax.jpl.nasa.gov
tneff@bfmny0.BFM.COM (Tom Neff) (09/15/90)
>| >do "/compass/c/worley/perl-3.0/lib/getopt.pl"; >| >| Come on people -- is it really necessary to leave this kind of line in a >| Perl script being distributed to the world? How about exercising a >| little reasonability when you post, and eliminating the weird custom >| directories instead of making thousands of individual users do it? > >And replace them with *what*? *Your* custom directory? How will >I know what that is? > >At least with a name like /compass/c/worley/blah/blah/blah, I know >enough to think "hey, maybe he's *not* talking about something from >the distribution there". No, but that's the point. Either the included packages are standard, or they aren't. If they're standard, the posted script should just invoke them by name without bizarre directories: do "getopt.pl"; and leave the individual user to add explicit pathing for his system, IF that's really necessary in preference to using -I. Whereas, if the packages are NOT standard, they should (a) be included in the distribution unless previously (and recently) posted; (b) NOT named the same as the standard packages, if the distinction between them is important; and (c) STILL referenced in the posted script without weird directory names. If the user has a copy of the nonstandard package he will install it someplace that he, and not the script author who lives on /perky/pat/foobar/6000SUX/lib/pustule/perlsubs, knows about. Mmm, that feels better. :-) -- Anthrax Rampant in Kirghizia: Oo*oO Tom Neff Izvestia Comment -- TASS * *O* * tneff@bfmny0.BFM.COM
marc@athena.mit.edu (09/17/90)
|> >At least with a name like /compass/c/worley/blah/blah/blah, I know |> >enough to think "hey, maybe he's *not* talking about something from |> >the distribution there". But if I use require '/afs/athena.mit.edu/user/m/marc/perl/menu.pl'; Then it's your fault for not having AFS on your system, with Internet connectivity and configured to know about the athena afs cell :-) Marc