I was looking at some startup scripts. particularly nginx. I noticed they have a block that looks like this
nginx=${NGINX-/usr/sbin/nginx}
prog=`/bin/basename $nginx`
conffile=${CONFFILE-/etc/nginx/nginx.conf}
lockfile=${LOCKFILE-/var/lock/subsys/nginx}
pidfile=${PIDFILE-/var/run/nginx.pid}
SLEEPMSEC=${SLEEPMSEC-200000}
I was trying to figure out what the '-' does in the middle of some of the $
lines
As an experiment I wrote my own script
#NGINX="b"
f=${NGINX-/etc/nginx/nginx.conf}
echo $f
If I keep the NGINX
line commented it prints /etc/nginx/nginx.conf
but if I uncomment it just prints b
So my question is what is the '-' doing and why would you want to use it this way?