The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-12-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
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}