Subject: bash: old script stopped working in new version of bash
Package: bash
Version: 5.0-4
Severity: normal
-- System Information:
Debian Release: 10.1
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-6-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8),
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages bash depends on:
ii base-files 10.3+deb10u1
ii debianutils 4.8.6.1
ii libc6 2.28-10
ii libtinfo6 6.1+20181013-2+deb10u1
Versions of packages bash recommends:
ii bash-completion 1:2.8-6
Versions of packages bash suggests:
pn bash-doc <none>
-- no debconf information
after updating to new version 10.1 Debian, old bash script stopped
working correctly. The thing is, script contains 2 functions which are
called in a loop. But it returns error for some reason.
script is pg_mass_back_error.txt and config for it in attachment
Error:
> Skipping schema template1
> ./pg_mass_back_error.txt: line 50: continue: only meaningful in a
`for', `while' , or `until' loop
PATH=/bin:/usr/bin:/usr/sap/HDB/HDB00/exe
export PGUSER=postgres
export PGPASSWORD=123456
#!/bin/bash
RED='\033[0;32m'
NC='\033[0m' # No Color
echo -e " ${RED}+++++STARTING+++++ ${NC} "
#papka scripta, dolzhna avtomatom opredelitsya
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#zadayem datu
FOLDER=$(date '+%Y-%m-%d_%H%M_%S')
#берем имя сервера
Backup_host="`hostname`"
echo loading configuration
####example of backup-all.conf
#PATH=/bin:/usr/bin:/usr/sap/HDB/HDB00/exe
#export PGUSER=postgres
#export PGPASSWORD=123456
cd $ROOTDIR
dos2unix $Backup_host/backup-all.conf
source $Backup_host/backup-all.conf
#formiruem papki
if [ ! -d "$ROOTDIR/$Backup_host" ]; then
echo "Creating $ROOTDIR/$Backup_host"
mkdir $ROOTDIR/$Backup_host
fi
if [ ! -d "$ROOTDIR/$Backup_host/$FOLDER" ]; then
echo "Creating $ROOTDIR/$Backup_host/$FOLDER"
mkdir $ROOTDIR/$Backup_host/$FOLDER
fi
#formiruem spisok vseh baz prinadlezhaschih polzovatelu
psql -h $Backup_host -t --command="select datname FROM pg_database;" -o
$ROOTDIR/$Backup_host/$FOLDER/$FOLDER.list
funck_skip(){
#propuskayem nenuzhnoe
if [ "$PG_DB" = 'template0' ];then
echo "Skipping schema $PG_DB"
continue;
fi
if [ "$PG_DB" = 'template1' ];then
echo "Skipping schema $PG_DB"
continue;
fi
}
func_export(){
funck_skip $PG_DB
pg_dump -h $Backup_host -d $PG_DB -f
$ROOTDIR/$Backup_host/$FOLDER/$PG_DB.psql
}
echo " $(date +%Y%m%d%H%M%S) start" > $ROOTDIR/$Backup_host/$FOLDER/$FOLDER.time
for PG_DB in $(sed 's/"//g' $Backup_host/$FOLDER/$FOLDER.list)
do
echo "$PG_DB"
func_export $PG_DB
done
echo " $(date +%Y%m%d%H%M%S) end" >>
$ROOTDIR/$Backup_host/$FOLDER/$FOLDER.time
#for statistics collection
echo determin schema sizes
du $Backup_host/$FOLDER/* -shBm >> $ROOTDIR/$Backup_host/DBs_size.txt