summaryrefslogtreecommitdiffhomepage
path: root/tests/posix/syntax.sh
blob: 40c7884c18110eec25a10da4e3ada52b5fa3ed8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# comment line
echo a # trailing comment
echo a;
echo b ; echo c
if true
then
  echo newline-if
fi
if true; then echo x
fi
for i in 1 2
do echo $i
done
for i
do echo no
done
while false
do :
done
case x in
  x)
    echo case-nl
    ;;
esac
case x in x) echo no-dsemi; esac
case x in x) echo 1;; y) echo 2
esac
case x in
esac
case x in (y) ;; (x|z) echo paren-pat ;; esac
{
  echo group-nl
}
(
  echo sub-nl
)
f()
{
  echo func-nl
}
f
g() if true; then echo func-if-body; fi
g
h() for i in 1; do echo func-for-body; done
h
k() ( echo func-subshell-body )
k
echo if then else fi for do done while until case esac in { }
echo "keywords as args: " if
if=1; then=2; echo $if $then
true &&
  echo and-continued
false ||
  echo or-continued
echo pipe-continued |
  cat
echo a; echo b; echo c;
! false && echo bang
if ! false; then echo bang-if; fi
{ echo g1; } ; { echo g2; }
(echo s1) ; (echo s2)
((echo nested-sub))  2>/dev/null || ( (echo nested-sub) )
( (echo spaced-nested) )
echo $(echo a)$(echo b)
echo a\
b\
c
x=1;y=2;echo $x$y
echo ${x}${y} "${x}"'${y}'
for i in a b; do
  for j in 1 2; do
    echo $i$j
  done
done
while :; do if true; then break; fi; done; echo broke
until false; do break; done
i=0; while [ $i -lt 2 ]; do i=$((i+1)); done; echo $i
echo "a;b" 'c&d' e\|f
echo 1>/dev/null; echo fd-prefix-ok
echo 1 >/dev/null; echo "(1 was an arg)"
echo a1>f1; cat f1
echo; echo; echo end