[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bad substitution breaks conditional statement
From: |
Martin Schulte |
Subject: |
Bad substitution breaks conditional statement |
Date: |
Mon, 12 Oct 2020 07:23:13 +0200 |
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-sec$
uname output: Linux t1 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24)
x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 3
Release Status: release
Description:
It looks as if a bad substitution detected inside a case of if continues the
script flow immediately after the conditional statement skipping the remaining
statements inside the conditional. Please take a look into section "Repeat-By:".
I detected this when running a script containing "${OPTARG@Q}" with a bash
4.1.5 where @Q is not yet supported - the script continued to run in a bad
manner so this bug might cause real troubles...
Repeat-By:
schulte@t1:~$ cat bad_substitutions_breaks_conditional
#!/bin/bash
x=y
case $x in
y)
echo "x has value ${x@q} - stop now!"
exit 1;;
esac
echo "running"
if [[ $x == y ]]; then
echo "x has value ${x@q} - stop now!"
exit 1
fi
echo "still running"
echo "x has value ${x@q} - stop now!"
exit 1
echo "and running"
schulte@t1:~$ ./bad_substitutions_breaks_conditional
./bad_substitutions_breaks_conditional: line 6: x has value ${x@q} - stop now!:
bad substitution
running
./bad_substitutions_breaks_conditional: line 11: x has value ${x@q} - stop
now!: bad substitution
still running
./bad_substitutions_breaks_conditional: line 15: x has value ${x@q} - stop
now!: bad substitution
- Bad substitution breaks conditional statement,
Martin Schulte <=