Tuesday 30 May 2006 06:48 skrev Iain Buchanan:
> I see this [ "x" != "x$BLAH" ] test all over the place, especially in
> the /etc/init.d scripts. Maybe -z is not standardised or something?
> Dunno why people use it.
Having searched a little further I have been able to locate a few scripts that
uses this in my bin folders. Common for those scripts are that they are sh
scripts and not bash scripts. Looking at 'man sh' you find no -z or -n but
they are in 'man bash'.
I think it's safe to say that .bashrc is a bash script and to make it even
more amusing (or whatever) Kevin does use both -z and -n a little further
down in his script.
All true. I do translations like this when I want to make it clear what's going on.
I worry that in the future seeing a test on "$PS1" will baffle me, even if I wrote
it. So I create a variable whose name indicates the motivation. I'm never
going to save enough time optimizing a .bashrc script to pay for one minutes'
worth of floundering later on.
I have no defense for the variance in coding style. I didn't notice it so I didn't
change it. I may still not do so -- I don't see the point.
It's a matter of taste.
++ kevin
--
Kevin O'Gorman, PhD