You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2022/05/05 08:54:10 UTC

[cassandra-harry] 01/02: fix(scripts/cassandra-harry): Fixing bash if condition

This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-harry.git

commit 87290c1fb4d0fec34c3a07a453719d599364f065
Author: Efraimov Oren <or...@gmail.com>
AuthorDate: Thu Jan 13 18:21:22 2022 +0200

    fix(scripts/cassandra-harry): Fixing bash if condition
    
    The correct way to check if variable is set is:
    ```bash
    if [ -z ${var+x} ]; then
       echo "var is unset"
    else
       echo "var is set to '$var'"
    fi
    ```
    
    For more information please check the following link:
    https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
---
 scripts/cassandra-harry | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/cassandra-harry b/scripts/cassandra-harry
index 94ee991..7cd4592 100755
--- a/scripts/cassandra-harry
+++ b/scripts/cassandra-harry
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-if [ "x$HARRY_HOME" == 'x' ]; then
+if [ -z ${HARRY_HOME1+x} ]; then
     HARRY_HOME=~/cassandra-harry
 fi
 
@@ -41,14 +41,13 @@ while [ $# -gt 0 ]; do
     esac
 done
 
-
-if [[ ! -z $node ]]; then
+if [ ! -z ${node+x} ]; then
     sed -i -e "s/contact_points:.*/contact_points: $node/g" $HARRY_HOME/conf/external.yaml
 fi
-if [[ ! -z $run_time ]]; then
+if [ ! -z ${run_time+x} ]; then
     sed -i -e "s/run_time:.*/run_time: $run_time/g" $HARRY_HOME/conf/external.yaml
 fi
-if [[ ! -z $run_time_unit ]]; then
+if [ ! -z ${run_time_unit+} ]; then
     sed -i -e "s/run_time_unit:.*/run_time_unit: \"$run_time_unit\"/g" $HARRY_HOME/conf/external.yaml
 fi
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org