Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[spec/sh-usage] Forgot this file in the last commit.
- Loading branch information
Andy Chu
committed
Jul 12, 2019
1 parent
9947939
commit bb457d4
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# | ||
# Usage: | ||
# ./sh-usage.test.sh <function name> | ||
|
||
#### sh -c | ||
$SH -c 'echo hi' | ||
## stdout: hi | ||
## status: 0 | ||
|
||
#### empty -c input | ||
# had a bug here | ||
$SH -c '' | ||
## stdout-json: "" | ||
## status: 0 | ||
|
||
#### empty stdin | ||
# had a bug here | ||
echo -n '' | $SH | ||
## stdout-json: "" | ||
## status: 0 | ||
|
||
#### args are passed | ||
$SH -c 'argv.py "$@"' dummy a b | ||
## stdout: ['a', 'b'] | ||
|
||
#### args that look like flags are passed after script | ||
script=$TMP/sh1.sh | ||
echo 'argv.py "$@"' > $script | ||
chmod +x $script | ||
$SH $script --help --help -h | ||
## stdout: ['--help', '--help', '-h'] | ||
|
||
#### args that look like flags are passed after -c | ||
$SH -c 'argv.py "$@"' --help --help -h | ||
## stdout: ['--help', '-h'] | ||
|
||
#### exit with explicit arg | ||
exit 42 | ||
## status: 42 | ||
|
||
#### exit with no args | ||
false | ||
exit | ||
## status: 1 |