From: dann frazier; Wednesday, January 07, 2004 11:18 PM
>
> On Tue, Dec 30, 2003 at 10:51:36AM -0800, Lombard, David N wrote:
> > Standard UNIX semantics for PATH interpret null components as the
> > current working directory.
> >
> > The attached patch does that for the several instances of which.
>
> thanks David, but this doesn't seem to work for me
Sorry for the slow response.
You put the 'return "ERROR\n"; line *inside* the foreach loop, you want
it after the loop. With that mod, it works as expected...
>
> [EMAIL PROTECTED]:/tmp$ cat /tmp/foo.pl
> #!/usr/bin/perl
>
> $ENV{PATH} =
> "/bin::/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin";
>
> sub which {
> my $prog = shift;
> # foreach my $path (split(':',$ENV{PATH})) {
> foreach my $path (split(':',$ENV{PATH},-1)) {
> $path ||= ".";
> if(-x "$path/$prog") {
> return "$path/$prog\n";
> }
> return "ERROR\n";
> }
> }
>
> print which("x");
> [EMAIL PROTECTED]:/tmp$ ls -l x
> -rwxr-xr-x 1 dannf dannf 0 2004-01-08 00:12 x
> [EMAIL PROTECTED]:/tmp$ /tmp/foo.pl
> ERROR
> [EMAIL PROTECTED]:/tmp$ PATH=$PATH:: which x
> /tmp/x
--
David N. Lombard
My comments represent my opinions, not those of Intel Corporation.
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Sisuite-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/sisuite-devel