Syntax error, but where?

Hi team

Currently writing a 'git clone script'.
I basicly check wether the $prj_path is its default or if its remote only, if that subdir exists.
Then it checks if the directory, and if so a .git/config exists, and pulls rather than clone the data.

In theory this would work just fine, obviously it doesnt :wink:
Also the editor i use provide syntax highlighting, but i fail to see it.

With: set -n

:) git $ ./clone nqq
# |                                    - GIT Handler - Clone repositry (0.1)                                     | #
line:42 works -- its this one
./clone: line 79: syntax error: unexpected end of file
2 git $

With: set -x

line:42 works -- its this one
+ source /home/sea/.config/dev-scripts/prjs/nqq/git.conf
++ URL=https://github.com/notepadqq/notepadqq.git
+ cat /home/sea/.config/dev-scripts/prjs/nqq/nqq.conf
# Project configuration for "notepadqq" (nqq)
prj_name="notepadqq"
prj_path="/home/sea/prjs/notepadqq"
useFAS=true
remoteOnly=true
+ echo 'line:54 works only with '\''set -x'\'' but not with '\''set -n'\'''
line:54 works only with 'set -x' but not with 'set -n'
+ echo 'line:55 works --==-- $remoteOnly is true in /bin/bash'
line:55 works --==-- $remoteOnly is true in /bin/bash
+ cd /home/sea/prjs/notepadqq
./clone: line 79: syntax error: unexpected end of file

Code:

  • Line 1 would be the shebang.
  • Lines 2-22 would be the disclaimer
  • Lines 23-35 would set most of the variables (persistent/default).

Assuming the syntax error is starting at the lowest section "Action & Display" its 'if-block'.

#--line 36
#	Variables
#
	if [ -z "$4" ]
	then	if [ ! -z "$1" ] && [ -d "$DIR_CFG/$1" ]
		then	LBL="$1"
echo "line:$LINENO works -- its this one"
		else	tui-echo "Please select the label to work with:"
			LBL=$(tui-select $(cd "$DIR_CFG";ls|$GREP -v [a-zA-Z]*\.))
		fi
	else	LBL="$4"
	fi
	[ -f "$CONF_GIT" ] && source "$CONF_GIT"
	source "$DIR_CFG/$LBL/$LBL.conf"
set -o nounset
set -n
	source "$DIR_CFG/$LBL/git.conf" || exit 1
cat "$DIR_CFG/$LBL/$LBL.conf"
echo "line:$LINENO works only with 'set -x' but not with 'set -n'"
echo "line:$LINENO works --==-- \$remoteOnly is $remoteOnly in $SHELL"
#
#	Display and action
#
	cd "$prj_path" || exit 1
	if $remoteOnly
	then	echo "line:$LINENO doesnt work -- already missing !!"
		
		if [ -d "$prj_name" ]
		then	echo "line:$LINENO works?"
			
			[ -d "$prj_name/.git" ] && \
				msg="Remote only git repositry already exists" || \
				msg="Cloning remote only repositry to $prj_path/$prj_name"
			
echo "line:$LINENO works"
			
			if tui-status $? "$msg"
			then	cd "$prj_name" 
				echo git pull
			else	echo git clone #"$URL" "$prj_name" ; cd "$prj_name" 
			fi
	else	tui-printf -S $RET_TODO "Regular project"
	fi

Any ideas what i've overseen please?
Thank you in advance

Replace

 if $remoteOnly

by

 if [ -n "$remoteOnly" ]

or

 if [ "true" = "$remoteOnly" ]

No change with neither of the two new.
Expect its now on line 81:

	#if $remoteOnly  # -- line 60
	#if [ -n "$remoteOnly" ]
	if [ "true" = "$remoteOnly" ]
	then ...

---------- Post updated at 21:38 ---------- Previous update was at 20:31 ----------

Forgot to re-add the same output:

line:55 works --==-- $remoteOnly is true in /bin/bash
+ cd /home/sea/prjs/notepadqq
./clone: line 81: syntax error: unexpected end of file
2 git $ 

where is the matching else/fi for this block?

                   if [ -d "$prj_name" ]         
                   then    echo "line:$LINENO works?"
1 Like

:doh: thanks alot