on master help sign in
Add a simple Bash script for syntax tests
commit02dcb01120b8f42073e8641fc32ad35ec597daa5 authorEthan P <eth-p+git@hidden.email> dateSun 4 Oct 2020, 00:32 (6 years ago) parent51d25e5
2 files changed+144
tests/syntax-tests/highlighted/Bash/simple.sh+72 tests/syntax-tests/source/Bash/simple.sh+72
tests/syntax-tests/highlighted/Bash/simple.shnew file+72
@@ -0,0 +1,72 @@
1+#!/usr/bin/env bash
2+function incompatible_function() {
3+ :
4+}
5+
6+compatible_function() {
7+ if ! [ "$1" == "yes" ]
8+ then
9+ return 3;:;
10+ fi
11+ 
12+ (
13+ exec 3>&1
14+ echo "finished! $@? $*." >&3 \
15+ | cat | bat - | cat
16+ exit 4
17+ ) || exit $?
18+}
19+
20+if command -v bat &> /dev/null; then
21+ var=1
22+ printf "%s...\n" "$(echo some text)"
23+ while true; do
24+ echo $var
25+
26+ if { [[ "$var" -eq 1 && ( true || false ) ]] || false 2>&1 1> /dev/null; } &> /dev/null; then
27+ var="$(cat <<< "two")"
28+ continue 1
29+ fi
30+
31+ case "$var" in
32+ "two") var="three" ;;
33+ three) var="four" ;;
34+ fo*r)
35+ var=five
36+ ;;
37+
38+ "fi"ve)
39+ var="$(
40+ cat << END
41+six > $var
42+END
43+ )"
44+ ;;
45+
46+ $'six\n' | *six*)
47+ echo "?"
48+ seven=seven
49+ while read -r line
50+ do
51+ var="$line"
52+ done << "HEREDOC"
53+1
54+2
55+$seven
56+HEREDOC
57+ ;;
58+
59+ *'sev'*)
60+ export var=eight
61+ unset var
62+ ;;
63+
64+ '')
65+ { incompatible_function && false; } || compatible_function "yes"
66+ break
67+ ;;
68+ esac
69+
70+ continue
71+ done
72+fi
tests/syntax-tests/source/Bash/simple.shnew file+72
@@ -0,0 +1,72 @@
1+#!/usr/bin/env bash
2+function incompatible_function() {
3+ :
4+}
5+
6+compatible_function() {
7+ if ! [ "$1" == "yes" ]
8+ then
9+ return 3;:;
10+ fi
11+
12+ (
13+ exec 3>&1
14+ echo "finished! $@? $*." >&3 \
15+ | cat | bat - | cat
16+ exit 4
17+ ) || exit $?
18+}
19+
20+if command -v bat &> /dev/null; then
21+ var=1
22+ printf "%s...\n" "$(echo some text)"
23+ while true; do
24+ echo $var
25+
26+ if { [[ "$var" -eq 1 && ( true || false ) ]] || false 2>&1 1> /dev/null; } &> /dev/null; then
27+ var="$(cat <<< "two")"
28+ continue 1
29+ fi
30+
31+ case "$var" in
32+ "two") var="three" ;;
33+ three) var="four" ;;
34+ fo*r)
35+ var=five
36+ ;;
37+
38+ "fi"ve)
39+ var="$(
40+ cat << END
41+six > $var
42+END
43+ )"
44+ ;;
45+
46+ $'six\n' | *six*)
47+ echo "?"
48+ seven=seven
49+ while read -r line
50+ do
51+ var="$line"
52+ done << "HEREDOC"
53+1
54+2
55+$seven
56+HEREDOC
57+ ;;
58+
59+ *'sev'*)
60+ export var=eight
61+ unset var
62+ ;;
63+
64+ '')
65+ { incompatible_function && false; } || compatible_function "yes"
66+ break
67+ ;;
68+ esac
69+
70+ continue
71+ done
72+fi