cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jackson Chung (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-2520) use -z to test for empty variables to make sh and dash happy
Date Wed, 20 Apr 2011 19:53:05 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022339#comment-13022339
] 

Jackson Chung commented on CASSANDRA-2520:
------------------------------------------

be ware some of them are *!=* while some are *=*

there is -z and -n to use, be ware the importance of ""

no "" on $TEST
{noformat}
$ cat test3.sh  
TEST=$1
echo "TEST is:$TEST"
if [ -z $TEST ]; then
        echo "TEST is zero-string"
else
        echo "TEST is not zero-string"
fi

if [ -n $TEST ]; then
        echo "TEST is non-zero string"
else
        echo "TEST is not a non-zero string"
fi


$ bash test3.sh
TEST is:
TEST is zero-string
*TEST is non-zero string*
$ dash test3.sh
TEST is:
TEST is zero-string
*TEST is non-zero string*
$

the "non-zero string" is incorrect
{noformat}

"" on $TEST
{noformat}
$ cat test2.sh
TEST=$1
echo "TEST is:$TEST"
if [ -z "$TEST" ]; then
        echo "TEST is zero-string"
else
        echo "TEST is not zero-string"
fi

if [ -n "$TEST" ]; then
        echo "TEST is non-zero string"
else
        echo "TEST is not a non-zero string"
fi


$ bash test2.sh
TEST is:
TEST is zero-string
TEST is not a non-zero string
$ dash test2.sh
TEST is:
TEST is zero-string
TEST is not a non-zero string
{noformat}

> use -z to test for empty variables to make sh and dash happy
> ------------------------------------------------------------
>
>                 Key: CASSANDRA-2520
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2520
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Packaging
>            Reporter: Jonathan Ellis
>            Assignee: Jonathan Ellis
>            Priority: Minor
>             Fix For: 0.7.5
>
>         Attachments: 2520-0.7.txt
>
>


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message