[
https://issues.apache.org/jira/browse/CASSANDRA-1443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16750863#comment-16750863
]
Murukesh Mohanan commented on CASSANDRA-1443:
---------------------------------------------
The syntax itself seems to be POSIX-compliant, but at least one tool used
isn't: {{which}}. {{which}} isn't POSIX; the POSIX way to look up the path of a
command seems to be {{command -v}} (see [this comprehensive post on Unix &
Linux|https://unix.stackexchange.com/a/85250/70524] for details).
Most uses of {{which}} were eliminated by [this patch for making C8 work with
Java 8 and
11|https://github.com/apache/cassandra/commit/6ba2fb9395226491872b41312d978a169f36fcdb];
there are still a few left:
{code}
$ grep 'which.*>' bin tools/bin/ -R
bin/cqlsh.py: which python$pyver > /dev/null 2>&1 && exec python$pyver "$0"
"$@"
bin/cassandra:if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS
ls / >/dev/null 2>/dev/null
bin/cassandra: which ldconfig > /dev/null 2>&1
bin/cqlsh: which python$pyver > /dev/null 2>&1 && exec python$pyver
"`python$pyver -c "import
os;print(os.path.dirname(os.path.realpath('$0')))"`/cqlsh.py" "$@"
{code}
It might be worthwhile to eliminate those as well.
---
Before that patch, many C* utilities used this check:
{code}
# Use JAVA_HOME if set, otherwise look for java in PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="`which java`"
fi
{code}
I noticed this when checking out ScyllaDB; their Docker images don't include
{{which}} and use an older version of various C* tools. Their solution was to
create a {{/bin/java}} symlink since the first check will then succeed (with
{{JAVA_HOME}} unset, that becomes {{/bin/java}}).
> shell scripts are not posix compliant
> -------------------------------------
>
> Key: CASSANDRA-1443
> URL: https://issues.apache.org/jira/browse/CASSANDRA-1443
> Project: Cassandra
> Issue Type: Bug
> Affects Versions: 0.6
> Reporter: Brandon Williams
> Assignee: Brandon Williams
> Priority: Minor
> Fix For: 0.6.6
>
> Attachments: 1443.txt
>
>
> Our shells scripts currently require bash, but invoke /bin/sh which may or
> may not be bash. Instead, we should make these scripts POSIX compliant so
> they work under any shell.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]