tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Various shell-scripting idioms in bin/daemon.sh
Date Tue, 16 Jul 2013 21:42:54 GMT
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" ])?

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?

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.

Thanks,
-chris


Mime
View raw message