[BusyBox] "which" mostly rewritten
Erik Andersen
andersen at lineo.com
Mon Jun 5 23:29:11 UTC 2000
On Mon Jun 05, 2000 at 06:50:29PM -0400, Pavel Roskin wrote:
> Hello!
>
> The current "which" is so buggy that it was easier for me to reimplement
> it. Some notes:
Go for it. Sorry for my bugs. I wrote "which" on my laptop during a boring
meeting a couple of weeks ago. I was obviously falling asleep during the
meeting to have missed so many obvious things. On the other hand, this is why
Open Source software is so much better...
> Instead of scanning whole directories with readdir() I decided to use
> stat(). This also gives us the possibility to ignore non-executable files.
This is a good optimization.
> The official "which" doesn't ignore directories, why should we bother?
Hmm, ok. I should have read the official which source when I wrote it (but I
was unplugged at the time).
> "which" without arguments doesn't crash anymore.
Oops.
> If PATH is not defined we shouldn't fallback to a default. It's a problem
> that should be reported. BTW, the official "which" crashes when run as
> "env - which foo" (LinuxPPC 1999 Q3).
Hmm. Sounds like a bug in the official which. on my box, which
is a shell script. whereis from util-linux also behaves properly
without PATH set, so lets keep this default in place.
> In order to process many arguments we should make a copy path_list,
> otherwise it cannot be reused.
>
> The official "which" stops processing arguments if it cannot find a file.
> The error message is printed on stdout. The exit code is 1. All this is
> now emulated.
k, cool
> I'll apply the patch myself with notes in Changelog. Ok?
>
> Pavel Roskin
Sure, but do put back the dafult path_list, as it is simple enough
to hard code a sane default.
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list