[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
while clause with two conditions does not execute when continue is used
From: |
rrd |
Subject: |
while clause with two conditions does not execute when continue is used |
Date: |
Wed, 21 Oct 2020 16:48:39 +0200 (CEST) |
Configuration Information [Automatically generated, do not change]:
Machine: aarch64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4
-L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='aarch64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='aarch64-suse-linux-gnu'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -fmessage-length=0
-grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong
-funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra -Wno-switch-enum
-Wno-unused-variable -Wno-unused-parameter -Wno-parentheses -ftree-loop-linear
-pipe -DBNC382214=0 -DIMPORT_FUNCTIONS_DEF=0 -fprofile-use -fprofile-correction
uname output: Linux rpi4-152b 5.3.18-lp152.44-default #1 SMP Wed Sep 30
18:51:43 UTC 2020 (914f31e) aarch64 aarch64 aarch64 GNU/Linux
Machine Type: aarch64-suse-linux-gnu
Bash Version: 4.4
Patch Level: 23
Release Status: release
Description:
See test script with while clause with two conditions.
The script should stop at value for i = 4 and j= 2. These are reached
but the conditions
are not tested because the end of the do block is reached with a
continue statement.
This can be seen by executing the script with ./test.sh 2>&1 | more
Script:
#!/bin/bash
# test error in while clause
#
set -x
up () {
i=$(($i+1))
[ $i -eq 5 ] && j=$(($j+1)) && i=0
}
i=0
j=0
# while loop should end when i=4 and j=2
while [ $i -ne 4 -o $j -ne 2 ]
do
if [ $i -eq 3 ]
then
up && continue
fi
echo i=$i j=$j
up
done
- while clause with two conditions does not execute when continue is used,
rrd <=