-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test/gold] Copy some more backtick test cases from issue #1449
Run like this: test/gold.sh test-autoconf-backtick And then see _tmp/shebang.txt and _tmp/osh.txt. (This reminds me the test/gold.sh harness is a little wonky)
- Loading branch information
Andy C
committed
Jan 15, 2023
1 parent
f41335d
commit a80f56d
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#! /bin/sh | ||
|
||
# From https://github.com/oilshell/oil/issues/1449 | ||
|
||
set -e | ||
|
||
nargs () { | ||
n_args=$# | ||
return 0 | ||
} | ||
|
||
check () { | ||
if [ "$1" = "$2" ]; then | ||
printf 'ok: %s\n' "$3" | ||
else | ||
printf 'FAIL: %s: got "%s" expected "%s"\n' "$3" "$1" "$2" | ||
status=1 | ||
fi | ||
} | ||
|
||
a="a b" | ||
|
||
nargs $a | ||
check $n_args 2 'nargs $a' | ||
|
||
nargs "$a" | ||
check $n_args 1 'nargs "$a"' | ||
|
||
nargs "$a" $a | ||
check $n_args 3 'nargs "$a" $a' | ||
|
||
n_args=`nargs "$a"; echo $n_args` | ||
check $n_args 1 '`nargs "$a"`' | ||
|
||
n_args=`nargs "$a" $a; echo $n_args` | ||
check $n_args 3 '`nargs "$a" $a`' | ||
|
||
eval "nargs \"$a\"" | ||
check $n_args 1 'eval "nargs \"$a\""' | ||
|
||
eval "nargs \"$a\" $a" | ||
check $n_args 3 'eval "nargs \"$a\" $a"' | ||
|
||
n_args=`eval "nargs \"$a\""; echo $n_args` | ||
check $n_args 1 'eval "nargs \"$a\""' | ||
|
||
n_args=`eval "nargs \"$a\" $a"; echo $n_args` | ||
check $n_args 3 'eval "nargs \"$a\" $a"' | ||
|
||
exit $status |