On Thursday, May 24 at 08:24 AM, quoth Ralf Wildenhues:
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
No, that won't work, because when $IFS is expanded, it will become this:
save_IFS=Which will essentially set save_IFS to "". You need to put them into quotes so that the shell doesn't parse-out the separators and use them as separators. So do this:
save_IFS="$IFS" IFS=: for dir in $PATH; do IFS="$save_IFS" ... done IFS="$save_IFS"Thus, when it's expanded, the shell won't make the special characters vanish, and it'll work more like this:
save_IFS=" \t\n" ~Kyle --We act as though comfort and luxury were the chief requirements of life, when all that we need to make us really happy is something to be enthusiastic about.
-- Charles Kingsley
Attachment:
pgpXmC3gAafpf.pgp
Description: PGP signature