[PATCH build 2/2] Clean up all conditional statements.

Tormod Volden lists.tormod at gmail.com
Wed Sep 15 06:01:06 PDT 2010


On Wed, Sep 15, 2010 at 2:36 PM, Trevor Woerner wrote:
> From: Trevor Woerner <twoerner at gmail.com>
>
> - use '-z' or '-n' instead of x"$VAR"
> - compare strings to strings and numbers to numbers
> - use ${variable:=word} to set default variable values
>
> Signed-off-by: Trevor Woerner <twoerner at gmail.com>
> ---
>  build.sh |   65 ++++++++++++++++++++++++++-----------------------------------
>  1 files changed, 28 insertions(+), 37 deletions(-)
>
> diff --git a/build.sh b/build.sh
> index fa6a321..20aee43 100755

Reviewed-by: Tormod Volden <lists.tormod at gmail.com>

On Wed, Sep 15, 2010 at 2:09 PM, Trevor Woerner wrote:
> Forcing the type to string using the 'x' works (which is what I assume
> to be the purpose of this notation), but so does:

BTW, in Bourne shell there is no notion of types, it is all
(substituted) strings. But beware of "lack of string" :) For instance,
[ -n $a ] returns true and [ -n "$a" ] returns false if a is not set.
The "[" function applies after parsing and string substitution, and
sees just [ -n ] in the first case. Which it does not handle well IMO.


More information about the xorg-devel mailing list