[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] IFS can not be made local?
From: |
Peng Yu |
Subject: |
[Help-bash] IFS can not be made local? |
Date: |
Thu, 25 Feb 2016 15:12:00 -0600 |
Hi, The following example shows that IFS can not be set local. Is it
so? If I want to temporarily change IFS, the best way is still to
assign it to a temp variable and recover the original value later on?
~~~
/tmp$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
function cmd {
local IFS
IFS=:
x=($1)
printf "%s\n" "address@hidden"
}
set -v
x=a:b
printf "%s\n" "address@hidden"
cmd "$x"
printf "%s\n" "address@hidden"
/tmp$ ./main.sh
x=a:b
printf "%s\n" "address@hidden"
a:b
cmd "$x"
a
b
printf "%s\n" "address@hidden"
a
b
~~~
--
Regards,
Peng
- [Help-bash] IFS can not be made local?,
Peng Yu <=