~ubuntu-branches/ubuntu/trusty/bash/trusty-security

« back to all changes in this revision

Viewing changes to tests/ifs.tests

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-03-03 22:52:05 UTC
  • mfrom: (1.3.5) (2.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20140303225205-87ltrt5kspeq0g1b
Tags: 4.3-1ubuntu1
* Merge with Debian; remaining changes:
  - skel.bashrc:
    - Run lesspipe.
    - Enable ls aliases.
    - Set options in ll alias to -alF.
    - Define an alert alias.
    - Enabled colored grep aliases.
  - etc.bash.bashrc:
    - Add sudo hint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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"