<<< Date Index >>>     <<< Thread Index >>>

Re: when using `which` send errors to /dev/null



* Cameron Simpson wrote on Thu, May 24, 2007 at 01:31:31AM CEST:
> On 23May2007 13:33, David Champion <dgc@xxxxxxxxxxxx> wrote:
> 
> | { 
> |     echo $PATH | tr : '\012' | while read dir; do
> 
> This is more robustly written:
> 
>   printf "%s\n" "$PATH" | tr : '\012' | while read -r dir; do

And even more robustly (and faster!) written like this:

  save_IFS=$IFS
  IFS=:
  for dir in $PATH; do
    IFS=$save_IFS
    ...
  done
  IFS=$save_IFS

Cheers,
Ralf