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?
$
signs are notorious in makefiles for causing trouble because they are interpreted as variable markers. Here just doubling the one in the first line should do the trick:
AppName\.html$$"
Also have a look at other posts to learn more about makefile escaping issues.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments