The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
What does this do in bash: ${pid:-}
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
What does this do in bash: ${pid:-}
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
3
(
permalink
)
10-12-2008
otheus
Moderator ala Mode
Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,893
Granted, null and zero-length are different, but the shell expands them the same way. So really there's no reason for the code as is. It could simply be:
Code:
if [ -z "$pidfile" ] ;then # blah blah fi
There's actually a simpler way.
Code:
pidfile=${pidfile:-/var/run/${1##*/}.pid}
otheus
View Public Profile
Visit otheus's homepage!
Find all posts by otheus
Find otheus's past nominations received
Find otheus's present nominations given