help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] How to set IFS temporarily? (along with assignment and array


From: Peng Yu
Subject: [Help-bash] How to set IFS temporarily? (along with assignment and array initiation)
Date: Mon, 16 Mar 2015 09:40:54 -0500

Hi,

I use the following 4 lines to set IFS temporarily. But it uses a
temporary variable OLD_IFS, which could be used by other accidentally.
Therefore, this piece of code is not entirely safe.

Does anybody have any better solution that this? Thanks.

~~~
OLD_IFS="$IFS"
IFS=$'\n'
array=($(printf "%s\n" 'a b' 'c d'))
IFS="$OLD_IFS"

printf "%s\n" "address@hidden"
~~~

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]