Re: when using `which` send errors to /dev/null
On 24May2007 08:11, Kyle Wheeler <kyle-mutt-dev@xxxxxxxxxxxxxx> wrote:
| What about:
| echo $PATH | while read -d : dir ; do
| ?
Whitespace in the $PATH may be mangled. This:
echo "$PATH"
will reserve that. I think -d (delimiter, yes?) is less portable than -r
(raw - don't parse backslashes).
Also, on some platforms (SysVish) echo may interpret backslashes as well
(\c - no newline, \n - a newline char, etc), which is why I went for:
printf "%s\n" "$PATH"
which avoids that.
Personally I think the IFS based solution suggested elsewhere in the
thread is better - it's totally portable and also faster.
Cheers,
--
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/
Freedom is the right to be wrong, not the right to do wrong.
- John G. Riefenbaker