summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEthan P <eth-p+git@hidden.email>2020-10-04 00:32:34 -0700
committerDavid Peter <sharkdp@users.noreply.github.com>2020-10-04 11:00:57 +0200
commit02dcb01120b8f42073e8641fc32ad35ec597daa5 (patch)
treeb9abf155d56912ea5a76846c407694828f3f14e5 /tests
parent51d25e5859171e060eb6edd6a1de758b4bc125ce (diff)
Add a simple Bash script for syntax tests
Diffstat (limited to 'tests')
-rw-r--r--tests/syntax-tests/highlighted/Bash/simple.sh72
-rw-r--r--tests/syntax-tests/source/Bash/simple.sh72
2 files changed, 144 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/Bash/simple.sh b/tests/syntax-tests/highlighted/Bash/simple.sh
new file mode 100644
index 00000000..301b923b
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Bash/simple.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+function incompatible_function() {
+ :
+}
+
+compatible_function() {
+ if ! [ "$1" == "yes" ]
+ then
+ return 3;:;
+ fi
+ 
+ (
+ exec 3>&1
+ echo "finished! $@? $*." >&3 \
+ | cat | bat - | cat
+ exit 4
+ ) || exit $?
+}
+
+if command -v bat &> /dev/null; then
+ var=1
+ printf "%s...\n" "$(echo some text)"
+ while true; do
+ echo $var
+
+ if { [[ "$var" -eq 1 && ( true || false ) ]] || false 2>&1 1> /dev/null; } &> /dev/null; then
+ var="$(cat <<< "two")"
+ continue 1
+ fi
+
+ case "$var" in
+ "two") var="three" ;;
+ three) var="four" ;;
+ fo*r)
+ var=five
+ ;;
+
+ "fi"ve)
+ var="$(
+ cat << END
+six > $var
+END
+ )"
+ ;;
+
+ $'six\n' | *six*)
+ echo "?"
+ seven=seven
+ while read -r line
+ do
+ var="$line"
+ done << "HEREDOC"
+1
+2
+$seven
+HEREDOC
+ ;;
+
+ *'sev'*)
+ export var=eight
+ unset var
+ ;;
+
+ '')
+ { incompatible_function && false; } || compatible_function "yes"
+ break
+ ;;
+ esac
+
+ continue
+ done
+fi
diff --git a/tests/syntax-tests/source/Bash/simple.sh b/tests/syntax-tests/source/Bash/simple.sh
new file mode 100644
index 00000000..29971625
--- /dev/null
+++ b/tests/syntax-tests/source/Bash/simple.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+function incompatible_function() {
+ :
+}
+
+compatible_function() {
+ if ! [ "$1" == "yes" ]
+ then
+ return 3;:;
+ fi
+
+ (
+ exec 3>&1
+ echo "finished! $@? $*." >&3 \
+ | cat | bat - | cat
+ exit 4
+ ) || exit $?
+}
+
+if command -v bat &> /dev/null; then
+ var=1
+ printf "%s...\n" "$(echo some text)"
+ while true; do
+ echo $var
+
+ if { [[ "$var" -eq 1 && ( true || false ) ]] || false 2>&1 1> /dev/null; } &> /dev/null; then
+ var="$(cat <<< "two")"
+ continue 1
+ fi
+
+ case "$var" in
+ "two") var="three" ;;
+ three) var="four" ;;
+ fo*r)
+ var=five
+ ;;
+
+ "fi"ve)
+ var="$(
+ cat << END
+six > $var
+END
+ )"
+ ;;
+
+ $'six\n' | *six*)
+ echo "?"
+ seven=seven
+ while read -r line
+ do
+ var="$line"
+ done << "HEREDOC"
+1
+2
+$seven
+HEREDOC
+ ;;
+
+ *'sev'*)
+ export var=eight
+ unset var
+ ;;
+
+ '')
+ { incompatible_function && false; } || compatible_function "yes"
+ break
+ ;;
+ esac
+
+ continue
+ done
+fi