I have bash script that I use regularly in my job to automate a large job. I was making some changes today, but everything seemed fine. The script itself is about 1700 lines long. The first part of the script is all good and runs through all the user input and logic just fine. It then proceeds into the core of the script and stops working at exactly line 875 (tested the script with bash -x
to find the break point). However, it breaks with the following error:
script.sh: line 1341: syntax error near unexpected token `;;'
script.sh: line 1341: ` ;;'
Line 1341 is in the middle of a case
statement. The following code is the beginning of that block of code where it is breaking:
if [[ $VAR1 = "TRUE" && $VAR2 = "VAL2" ]]; then
VERSION=`XXXXXXXXXXXXXXXX`
## Set variables based on location $VAR3
case $VAR3 in
STR1 )
case $VERSION in
STR2 )
VAR4 = "STR5"
VAR5 = "STR6"
VAR6 = "STR7"
VAR7 = "STR8"
Line 1341 ---> ;;
STR3 )
VAR4="STR9"
VAR5="STR10"
VAR6="STR11"
VAR7="STR12"
;;
STR4 )
VAR4="STR13"
VAR5="STR14"
VAR6="STR15"
VAR7="STR16"
;;
esac
VAR8="STR17"
VAR9="STR18"
VAR10=1
VAR11="STR19"
;;
Because of the sensitive nature of what I do, I obviously had to remove quite a bit of information. I know this may make things more difficult to help me with. However, all VAR##="STR##" are standard variable declarations with string values, nothing special (no variable substitution, etc). All the variables are used later in the script. The code for VERSION returns a string value, which is used in the nested case
.
The script was working fine up until my changes today, but I really didn't touch this section, with the exception of tweaking some of the STR values. I tried setting $VAR3
and $VERSION
variables in quotes "", as well as the STR values used as the cases. I tried taking out this block entirely, only to have it fail on the next block (STR1 has a different value thus change the variable declarations). I have it output to the console what it is doing as well as checks for errors after most functions. There is nothing out of the ordinary on the console and nothing in the error log.
Any help would be appreciated, and I know I'm asking a lot.
By the way here is the code around line 875 where the script stops running (no errors generated based on the code here). Again, with bash -x
I could see the VAR2 variable get set, but the script breaks before the next for
loop starts.
## Create file ##
echo 'Creating files . . . '
j=0
p=1111
if [ $VAR1 = "TRUE" ]
then
VAR2=1
else
VAR2=2
fi
for i in `seq 1 $HOWMANY`; do <----Line 875
echo -n "Creating file . . . "
echo "XXXXXXXXXXX
Thanks again.