stef@zweig.sun (Stephane Payrard) (08/14/90)
Assumiong there is no file named argument in the current directory,
pipe this article in 'perl -x argument'. The output is:
Can't open perl script "argument": No such file or directory
I would have been expected the string 'argument' to be printed.
The script executed being the embedded script, it makes non sense to
expect a filename as argument. In this respect, the -x switch should
behave like the -e switch.
#! /usr/bin/perl
print $ARGV[0];
__END__
stef
--
Stephane Payrard -- stef@sun.com -- (415) 336 3726
Sun Microsystems -- 2550 Garcia Avenue -- M/S 10-09 -- Mountain View CA 94043
composer@bucsf.bu.edu (Jeff Kellem) (08/14/90)
In article <STEF.90Aug13172814@zweig.sun> stef@zweig.sun (Stephane Payrard) writes: > Assumiong there is no file named argument in the current directory, > pipe this article in 'perl -x argument'. The output is: > Can't open perl script "argument": No such file or directory > > I would have been expected the string 'argument' to be printed. Actually, perl allows an optional directory name as an argument to the `-x' option. If the directory name is specified, perl will chdir to the directory before executing the script. It currently is either half-broken or just not documented specifically enough right now. Judging from the man page, it looks like a space should be allowed (so, [on another note] there should be no space between the `-i' option and the arg in the man page then, right??). But, the code in `perly.c' only deals with `-xdirectory'. Is a space supposed to be allowed between `-x' and `directory'?? It seems like it should be okay. But, a fix depends on which is supposed to be correct. So, Larry, are both perl -xdirectory and perl -x directory supposed to be legal? To allow the latter should be a simple fix. Cheers... -jeff Jeff Kellem INTERNET: composer@cs.bu.edu (or composer@bu.edu) UUCP: ...!harvard!bu-cs!composer
stef@zweig.sun (Stephane Payrard) (08/14/90)
I made myself not very clear.
Reading the documentation, one can expect 'argument'
in 'perl -x argument' to be:
1/ the name of a directory
or
2/ the first argument (ie: $ARGV[0] ) passed to the embedded executed
shell-script
...but certainly not
3/ the name of a perl-script to be executed as suggested by the error
message you get on piping this article (which has a perl-script
embedded) to 'perl -x argument' with `argument' being the name an
empty file in the current directory.
#! /usr/bin/perl
print $ARGV[0];
__END__
--
Stephane Payrard -- stef@sun.com -- (415) 336 3726
Sun Microsystems
2550 Garcia Avenue M/S 10-09 Mountain View CA 94043
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/15/90)
In article <COMPOSER.90Aug14001232@bucsf.bu.edu> composer@cs.bu.edu writes: : So, Larry, are both : perl -xdirectory : and : perl -x directory : supposed to be legal? : : To allow the latter should be a simple fix. Yes the fix is simple, but it would bust perl -x arg1 arg2 arg3 In general, the space can be optional on a switch only if the argument is required. And I want to allow a simple perl -x for the cases in which it doesn't matter which directory it runs in. : In article <STEF.90Aug13172814@zweig.sun> : stef@zweig.sun (Stephane Payrard) writes: : : > Assumiong there is no file named argument in the current directory, : > pipe this article in 'perl -x argument'. The output is: : > Can't open perl script "argument": No such file or directory : > : > I would have been expected the string 'argument' to be printed. I would too. I guess that makes it a bug. Larry