Shells in OCaml
1Field separation tests.
2
3 $ cat > test.sh << EOF
4 > count_args () {
5 > echo "Got \$# args"
6 > }
7 > echo "IFS \$IFS"
8 > VAR_TO_SPLIT="This is a var to split hahaha"
9 > count_args \$VAR_TO_SPLIT
10 > OLD_IFS="\$IFS"
11 > IFS=" "
12 > count_args \$VAR_TO_SPLIT
13 > IFS=" "
14 > count_args \$VAR_TO_SPLIT
15 > IFS="\$OLD_IFS"
16 > count_args \$VAR_TO_SPLIT
17 > EOF
18
19 $ sh test.sh
20 IFS
21
22 Got 7 args
23 Got 6 args
24 Got 2 args
25 Got 7 args
26 $ msh test.sh
27 IFS
28
29 Got 7 args
30 Got 6 args
31 Got 2 args
32 Got 7 args
33