smiklosovic commented on code in PR #1950:
URL: https://github.com/apache/cassandra/pull/1950#discussion_r1112835095


##########
bin/nodetool:
##########
@@ -22,35 +22,8 @@ if [ "`basename "$0"`" = 'nodeprobe' ]; then
     echo "***************************************************************" >&2
 fi
 
-if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
-    # Locations (in order) to use when searching for an include file.
-    for include in "`dirname "$0"`/cassandra.in.sh" \
-                   "$HOME/.cassandra.in.sh" \
-                   /usr/share/cassandra/cassandra.in.sh \
-                   /usr/local/share/cassandra/cassandra.in.sh \
-                   /opt/cassandra/cassandra.in.sh; do
-        if [ -r "$include" ]; then
-            . "$include"
-            break
-        fi
-    done
-elif [ -r "$CASSANDRA_INCLUDE" ]; then
-    . "$CASSANDRA_INCLUDE"
-fi
-
-if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
-    echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
-    exit 1
-fi
-
-# Run cassandra-env.sh to pick up JMX_PORT
-if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
-    JVM_OPTS_SAVE=$JVM_OPTS
-    MAX_HEAP_SIZE_SAVE=$MAX_HEAP_SIZE
-    . "$CASSANDRA_CONF/cassandra-env.sh"
-    MAX_HEAP_SIZE=$MAX_HEAP_SIZE_SAVE
-    JVM_OPTS="$JVM_OPTS_SAVE"
-fi
+ENV_PRESERVE="$ENV_PRESERVE MAX_HEAP_SIZE JVM_OPTS"
+. ./cassandra-conf.sh

Review Comment:
   Imagine you are developing some 3rd party command-line tool which needs the 
very same boilerplate as any other command we ship in Cassandra distribution, 
in `tools` or `bin` or what have you.
   
   While implementing the script which executes that main class of yours, you 
basically take some already existing script as a skeleton and then you tweak it 
in such a way that the java command at the end of that file executes your main 
class.
   
   When we eventually plan to incorporate this cassandra-conf.sh stuff into 
every script, one can imagine that the very same script will be called in our 
custom script as well.
   
   Here, we are making an assumption that `cassandra-conf.sh` will be in the 
same directory as `nodetool` script is.
   
   But what it is not? What if you have some 3rd party script which is located 
it a different directory from nodetool's one? What if that script is in 
`/tmp/mycustomscripts/mytool` ? Then sourcing `. cassandra-conf.sh` will not 
work, will it? 
   
   So for that reason, the loading of `. cassandra-conf.sh` has to be a little 
bit smarter about that we should souce it in such a way that the script it is 
sourced in can be in theory wherever. That is what my suggestion about sourcing 
with above is about.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to