summaryrefslogtreecommitdiffhomepage
path: root/tests/zash/deep-arith.sh
blob: f3af9e913810d64e1bcff83d470f549205f7fa84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# shellcheck disable=SC2016
# 200000 nested parentheses must be reported, not overflow the stack.
# dash and bash both crash on this.  The expression goes into the shell's
# stdin, not into a file: on z/OS a redirect of another program's output gets
# tagged and converted, which garbles a generated ASCII script.  Only the head
# of the message is looked at, because some seds choke on a 400 KB line.
command -v python3 >/dev/null 2>&1 || exit 77
gen() { python3 -c 'print("echo $((" + "("*200000 + "1" + ")"*200000 + "))")'; }
gen | "$TSH" >/dev/null 2>&1
echo "status $?"
if gen | "$TSH" 2>&1 >/dev/null | head -c 200 | grep -q "expression nested too deeply"; then
    echo "message ok"
fi
"$TSH" -c 'echo $(((((1)))))'