I am trying to install something in tomcat webapp. This is beginning of my install target:
tomcat=`locate --regex "^(/var/lib/tomcat[0-9]{1,2}/webapps/[^/]+/)AppName\.html$" -l 1 | tr -d "\n"`
echo "Tomcat: $tomcat"
# If the string is empty (no path matched) or the path does not exists (that should never really happen)
# terminate
if [ -z "$tomcat" ] || [ ! -f "$tomcat" ]; then
echo "Application not found on filesystem."
exit 404
fi
However this is the output:
tomcat=`locate --regex "^(/var/lib/tomcat[0-9]{1,2}/webapps/[^/]+/)AppName\.html -l 1 | tr -d "\n"`
/bin/sh: 1: Syntax error: Unterminated quoted string
makefile:77: recipe for target 'install' failed
make: *** [install] Error 2
Everyone else claims that you can use ` (backtick) to assign command stdout output into variable. I even used tr -d "\n" to delete all newline characters, may they appear. And the code works flawlessly in shell:
XXXXX@debianvirtualbox:~$ tomcat=`locate --regex "^(/var/lib/tomcat[0-9]{1,2}/webapps/[^/]+/)AppName\.html$" -l 1 | tr -d "\n"`
XXXXX@debianvirtualbox:~$ echo $tomcat
/var/lib/tomcat8/webapps/websight/AppName.html
What else is there to fix?