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