OILS / test / gold / autoconf-backtick.sh View on Github | oilshell.org

50 lines, 33 significant
1#! /bin/sh
2
3# From https://github.com/oilshell/oil/issues/1449
4
5set -e
6
7nargs () {
8 n_args=$#
9 return 0
10}
11
12check () {
13 if [ "$1" = "$2" ]; then
14 printf 'ok: %s\n' "$3"
15 else
16 printf 'FAIL: %s: got "%s" expected "%s"\n' "$3" "$1" "$2"
17 status=1
18 fi
19}
20
21a="a b"
22
23nargs $a
24check $n_args 2 'nargs $a'
25
26nargs "$a"
27check $n_args 1 'nargs "$a"'
28
29nargs "$a" $a
30check $n_args 3 'nargs "$a" $a'
31
32n_args=`nargs "$a"; echo $n_args`
33check $n_args 1 '`nargs "$a"`'
34
35n_args=`nargs "$a" $a; echo $n_args`
36check $n_args 3 '`nargs "$a" $a`'
37
38eval "nargs \"$a\""
39check $n_args 1 'eval "nargs \"$a\""'
40
41eval "nargs \"$a\" $a"
42check $n_args 3 'eval "nargs \"$a\" $a"'
43
44n_args=`eval "nargs \"$a\""; echo $n_args`
45check $n_args 1 'eval "nargs \"$a\""'
46
47n_args=`eval "nargs \"$a\" $a"; echo $n_args`
48check $n_args 3 'eval "nargs \"$a\" $a"'
49
50exit $status