shell script question

Darrin Chandler dwchandler at stilyagin.com
Mon Jul 31 17:38:41 MST 2006


On Mon, Jul 31, 2006 at 05:11:10PM -0700, Jerry Davis wrote:
> > 
> > if [ "X" != "X" ];
> > 
> > which is the same as "" != "".
> > 
> > As I said, though, it's been a while since I learned to do that so my
> > memory could be shot.
> 
> no. your memory is just fine.
> I remember having to do this even on newer shells like ksh on some
> other systems like HPUX. Linux would handle things fine. HPUX vs. AIX
> vs linux can trip you up.
> 
> in bash I think you can do if [ -z $var ] and that will do it too.

That works in ksh too (at least pdksh), but you never know if it's going
to work in plain old sh, on whatever system you're on.

People who write for multiple platforms usually get into the habit of
doing things the "old" way, since it will work just about everywhere.
It's different if you're scripting only for systems you control. Then
you can use features introduced in the latest point release if you like.
;)

-- 
Darrin Chandler            |  Phoenix BSD Users Group
dwchandler at stilyagin.com   |  http://bsd.phoenix.az.us/
http://www.stilyagin.com/  |


More information about the PLUG-discuss mailing list