-
-
Notifications
You must be signed in to change notification settings - Fork 21
Replace Bash scripts with POSIX sh scripts #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
| #!/bin/sh | ||
|
|
||
| make clean && \ | ||
| make bench && \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
| #!/bin/sh | ||
|
|
||
| echo "Compiling with -fprofile-generate" | ||
| make clean && \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,71 @@ | ||
| #!/bin/bash | ||
| #!/bin/sh | ||
|
|
||
| echo -e "\nINFO: Test the positional arguments (interpreter)\n" | ||
| chaos tests/everything.kaos && echo -e "\nOK\n\n" && \ | ||
| chaos -d tests/everything.kaos && echo -e "\nOK\n\n" && \ | ||
| printf "\nINFO: Test the positional arguments (interpreter)\n" | ||
| chaos tests/everything.kaos && printf "\nOK\n\n" && \ | ||
| chaos -d tests/everything.kaos && printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test no arguments (REPL)\n" | ||
| echo "exit" | chaos && echo -e "\nOK\n\n" && \ | ||
| echo "exit" | chaos -d && echo -e "\nOK\n\n" && \ | ||
| printf "\nINFO: Test no arguments (REPL)\n" | ||
| echo "exit" | chaos && printf "\nOK\n\n" && \ | ||
| echo "exit" | chaos -d && printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test compilation variants with short options\n" | ||
| printf "\nINFO: Test compilation variants with short options\n" | ||
| chaos -c tests/everything.kaos && \ | ||
| [ -f build/main ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything && \ | ||
| [ -f build/everything ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything -e "-ggdb" && \ | ||
| [ -f build/everything ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything -e "-ggdb" -k && \ | ||
| [ -f build/everything ] && \ | ||
| [ -f build/everything.c ] && \ | ||
| [ -f build/everything.h ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything -e "-ggdb" -kd && \ | ||
| [ -f build/everything ] && \ | ||
| [ -f build/everything.c ] && \ | ||
| [ -f build/everything.h ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test compilation variants with long options\n" | ||
| printf "\nINFO: Test compilation variants with long options\n" | ||
| chaos --compile tests/everything.kaos && \ | ||
| [ -f build/main ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos --compile tests/everything.kaos --output everything && \ | ||
| [ -f build/everything ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos --compile tests/everything.kaos --output everything --extra "-ggdb" && \ | ||
| [ -f build/everything ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos --compile tests/everything.kaos --output everything --extra "-ggdb" --keep && \ | ||
| [ -f build/everything ] && \ | ||
| [ -f build/everything.c ] && \ | ||
| [ -f build/everything.h ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
| chaos --compile tests/everything.kaos --output everything --extra "-ggdb" --keep --debug && \ | ||
| [ -f build/everything ] && \ | ||
| [ -f build/everything.c ] && \ | ||
| [ -f build/everything.h ] && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test other arguments\n" | ||
| printf "\nINFO: Test other arguments\n" | ||
| chaos -h && chaos --help && \ | ||
| chaos -v && chaos --version && \ | ||
| chaos -l && chaos --license && \ | ||
| chaos -u tests/everything.kaos && chaos --unsafe tests/everything.kaos && \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test invalid argument messages with short options\n" | ||
| chaos -c || echo -e "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o || echo -e "\nOK\n\n" && \ | ||
| chaos -o everything || echo -e "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything -e || echo -e "\nOK\n\n" && \ | ||
| printf "\nINFO: Test invalid argument messages with short options\n" | ||
| chaos -c || printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o || printf "\nOK\n\n" && \ | ||
| chaos -o everything || printf "\nOK\n\n" && \ | ||
| chaos -c tests/everything.kaos -o everything -e || printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: Test other erroring arguments\n" | ||
| printf "\nINFO: Test other erroring arguments\n" | ||
| chaos --no_such_arg || \ | ||
| chaos no_such_file.kaos || \ | ||
| echo -e "\nOK\n\n" && \ | ||
| printf "\nOK\n\n" && \ | ||
|
|
||
| echo -e "\nINFO: CLI arguments are OK." | ||
| printf "\nINFO: CLI arguments are OK." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,33 @@ | ||
| #!/bin/bash | ||
| #!/bin/sh | ||
|
|
||
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| OSTYPE=$(uname --kernel-name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| DIR="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )" | ||
|
|
||
| for filepath in $(find $DIR -maxdepth 1 -name '*.kaos'); do | ||
| filename=$(basename $filepath) | ||
| for filepath in $(find "$DIR" -maxdepth 1 -name '*.kaos'); do | ||
| filename=$(basename "$filepath") | ||
| testname="${filename%.*}" | ||
|
|
||
| if [[ "$testname" == "exit_"* ]]; then | ||
| if [ "$testname" = "exit_*" ]; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is weird - can a file |
||
| continue | ||
| fi | ||
|
|
||
| SKIP_TESTS="syntax_error preemptive" | ||
|
|
||
| if echo $SKIP_TESTS | grep -w $testname > /dev/null; then | ||
| if echo "$SKIP_TESTS" | grep -w "$testname" > /dev/null; then | ||
| continue | ||
| fi | ||
|
|
||
| echo -e "\n\n(interpreter) Running memcheck: ${testname}\n" | ||
| printf "\n\n(interpreter) Running memcheck: %s\n" "$testname" | ||
|
|
||
| if [[ "$OSTYPE" == "linux"* ]]; then | ||
| valgrind --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --error-exitcode=1 chaos $DIR/$filename || exit 1 | ||
| elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
| /tmp/DrMemory/bin64/drmemory -exit_code_if_errors 1 -suppress tests/shell/suppress.mac.txt -- chaos $DIR/$filename || exit 1 | ||
| if [ "$OSTYPE" = "Linux" ]; then | ||
| valgrind --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --error-exitcode=1 chaos "$DIR/$filename" || exit 1 | ||
| elif [ "$OSTYPE" = "Darwin" ]; then | ||
| /tmp/DrMemory/bin64/drmemory -exit_code_if_errors 1 -suppress tests/shell/suppress.mac.txt -- chaos "$DIR/$filename" || exit 1 | ||
| fi | ||
| done | ||
|
|
||
| for dirpath in $(find $DIR -mindepth 1 -maxdepth 1 -type d); do | ||
| if [ -f $dirpath/memcheck.sh ]; then | ||
| $dirpath/memcheck.sh | ||
| for dirpath in $(find "$DIR" -mindepth 1 -maxdepth 1 -type d); do | ||
| if [ -f "$dirpath/memcheck.sh" ]; then | ||
| "$dirpath/memcheck.sh" | ||
| fi | ||
| done | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be POSIX-compliant? I don't think
catis needed, but I didn't look it up in the spec...Edit: Needless to say using
cathere is always better because of better error handling. So this is just my thinking out loud.I've checked it and the POSIX manual isn't explicit about this being disallowed or "non-POSIX" but e.g.
dashdoesn't seem to do the right thing, so I suppose it's definitely not portable and probably generally not considered POSIX compliant.So thanks for spotting this (I myself wouldn't use
$(<...because as I wrote above - error handling is better withcat).