blob: 763e2a001da083c055f68b298f3b198be75886cf [file] [log] [blame]
Jari Aalto7117c2d2002-07-17 14:10:11 +00001OIFS="$IFS"
2IFS=":$IFS"
3eval foo="a:b:c"
4IFS="$OIFS"
5echo $foo
6
7OIFS=$IFS
8IFS=":$IFS"
9foo=$(echo a:b:c)
10IFS=$OIFS
11
12for i in $foo
13do
14 echo $i
15done
16
17OIFS=$IFS
18IFS=":$IFS"
19foo=`echo a:b:c`
20IFS=$OIFS
21
22for i in $foo
23do
24 echo $i
25done
26
27DEFIFS=$' \t\n'
28
29# local copy of IFS that shadows global version
30function f
31{
32 typeset IFS=:
33
34 echo $1
35}
36
37function ff
38{
39 echo $1
40}
41
42f a:b:c:d:e
43x=a:b:c:d:e
44echo $x
45
46IFS=: ff a:b:c:d:e
47echo $x
48
49# doesn't get word split
50IFS=$DEFIFS
51# variable assignment doesn't use new value for word splitting
52IFS=: echo $x
53# but does this time because of the eval
54IFS=: eval echo \$x
55
56# in posix mode, assignments preceding special builtins and functions are global
57set -o posix
58IFS=: export x
59echo $x
60
61IFS="$DEFIFS"