Reputation: 1035
It's part of code in a makefile, there are two $$ to expand variable CONTINUE,why? Are there any special meaning?
read -r -p "Overwrite your existing default nginx configuration? [y/N] " CONTINUE;
if [ "$$CONTINUE" == "y" ] || [ "$$CONTINUE" == "Y" ]; then
echo "y"
else
echo "n"
fi
Upvotes: 0
Views: 353
Reputation: 128
$$ is (simply put) escaping in a Makefile because $-Vars also exists there. To use the variable for bash (which also needs $var) you have to write $$
pre edit (topic changes from "script" to "makefile")
Does this script even work?
# ./test.sh
Overwrite your existing default nginx configuration? [y/N] y
n
Change it to a single $.
$$ expands to the PID of the executing bash shell
($$) Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the invoking shell, not the subshell.
Upvotes: 1