On 17 July 2013 12:59, Mladen Turk <mt...@apache.org> wrote:
> On 07/16/2013 11:42 PM, Christopher Schultz wrote:
>>
>> All,
>>
>> While doing the trivial fix for
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=55268, I noticed a
>> few idioms being used in bin/daemon.sh that struck me as odd. For example:
>>
>> while [ ".$1" != . ]
>> do
>>    case "$1" in
>>      --java-home )
>>          JAVA_HOME="$2"
>>          shift; shift;
>>          continue
>>      ;;
>>
>>
>> This example actually illustrates the two main questions I had:
>>
>> 1. Why use [ ".$FOO" != . ] instead of simply [ -n "$FOO" ] (Corollary:
>> why use [ ".$FOO" = . ] instead of [ -z "$FOO" ])?
>>
>
> Because some shell scripts does dot handle -z or -n well.
>
>
>> 2. Why have a "continue" at the end of every case option, since the
>> whole body of the while loop is nothing but the case construct?
>>
>
> That might be an extra directive, true.
> Probably a leftover from multiple case directives in while loop.
>

But safer than forgetting to add the continue if another case is ever added.

>
>
>> I may be spoiled by using Linux and bash for most of my career, but I
>> believe these are fairly standard POSIX-compliant things that should
>> work on all *NIX systems.
>>
>
> Sadly that's not the case IMHO.

May I suggest a short comment is added to the script to document why
-z and -n are not used?
Someone else reading the script in the future is going to wonder the same.

>
> Regards
> --
> ^TM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to