You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/03 15:44:00 UTC
[jira] [Commented] (KAFKA-2254) The shell script should be
optimized , even kafka-run-class.sh has a syntax error.
[ https://issues.apache.org/jira/browse/KAFKA-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531567#comment-16531567 ]
ASF GitHub Bot commented on KAFKA-2254:
---------------------------------------
omkreddy closed pull request #3693: KAFKA-2254: Use double quote to prevent globbing and word splitting in shell scripts
URL: https://github.com/apache/kafka/pull/3693
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/bin/connect-distributed.sh b/bin/connect-distributed.sh
index 08fc57b9c51..40af26fddc9 100755
--- a/bin/connect-distributed.sh
+++ b/bin/connect-distributed.sh
@@ -20,7 +20,7 @@ then
exit 1
fi
-base_dir=$(dirname $0)
+base_dir="$(dirname "$0")"
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
@@ -42,4 +42,4 @@ case $COMMAND in
;;
esac
-exec $(dirname $0)/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectDistributed "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectDistributed "$@"
diff --git a/bin/connect-standalone.sh b/bin/connect-standalone.sh
index 931cc37c9a4..67576161a04 100755
--- a/bin/connect-standalone.sh
+++ b/bin/connect-standalone.sh
@@ -20,7 +20,7 @@ then
exit 1
fi
-base_dir=$(dirname $0)
+base_dir="$(dirname "$0")"
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
@@ -42,4 +42,4 @@ case $COMMAND in
;;
esac
-exec $(dirname $0)/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectStandalone "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectStandalone "$@"
diff --git a/bin/kafka-acls.sh b/bin/kafka-acls.sh
index 8fa65542e10..7807331f45c 100755
--- a/bin/kafka-acls.sh
+++ b/bin/kafka-acls.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.AclCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.AclCommand "$@"
diff --git a/bin/kafka-broker-api-versions.sh b/bin/kafka-broker-api-versions.sh
index 4f560a0a60c..648400bb575 100755
--- a/bin/kafka-broker-api-versions.sh
+++ b/bin/kafka-broker-api-versions.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.BrokerApiVersionsCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.BrokerApiVersionsCommand "$@"
diff --git a/bin/kafka-configs.sh b/bin/kafka-configs.sh
index 2f9eb8c239f..8943d5914a1 100755
--- a/bin/kafka-configs.sh
+++ b/bin/kafka-configs.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.ConfigCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.ConfigCommand "$@"
diff --git a/bin/kafka-console-consumer.sh b/bin/kafka-console-consumer.sh
index dbaac2b83b1..3944ba0f1e8 100755
--- a/bin/kafka-console-consumer.sh
+++ b/bin/kafka-console-consumer.sh
@@ -18,4 +18,4 @@ if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.ConsoleConsumer "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.ConsoleConsumer "$@"
diff --git a/bin/kafka-console-producer.sh b/bin/kafka-console-producer.sh
index e5187b8b533..a8752a9920c 100755
--- a/bin/kafka-console-producer.sh
+++ b/bin/kafka-console-producer.sh
@@ -17,4 +17,4 @@
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.ConsoleProducer "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.ConsoleProducer "$@"
diff --git a/bin/kafka-consumer-groups.sh b/bin/kafka-consumer-groups.sh
index feb063de756..2de158fecee 100755
--- a/bin/kafka-consumer-groups.sh
+++ b/bin/kafka-consumer-groups.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.ConsumerGroupCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.ConsumerGroupCommand "$@"
diff --git a/bin/kafka-consumer-perf-test.sh b/bin/kafka-consumer-perf-test.sh
index 77cda721d6c..96a0343d7e2 100755
--- a/bin/kafka-consumer-perf-test.sh
+++ b/bin/kafka-consumer-perf-test.sh
@@ -17,4 +17,4 @@
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.ConsumerPerformance "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.ConsumerPerformance "$@"
diff --git a/bin/kafka-delete-records.sh b/bin/kafka-delete-records.sh
index 8726f919992..d71b121a71a 100755
--- a/bin/kafka-delete-records.sh
+++ b/bin/kafka-delete-records.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.DeleteRecordsCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.DeleteRecordsCommand "$@"
diff --git a/bin/kafka-log-dirs.sh b/bin/kafka-log-dirs.sh
index dc16edcc7c5..ac5c7dc2f1e 100755
--- a/bin/kafka-log-dirs.sh
+++ b/bin/kafka-log-dirs.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.LogDirsCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.LogDirsCommand "$@"
diff --git a/bin/kafka-mirror-maker.sh b/bin/kafka-mirror-maker.sh
index 981f2711af9..5dc18f011ff 100755
--- a/bin/kafka-mirror-maker.sh
+++ b/bin/kafka-mirror-maker.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.MirrorMaker "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.MirrorMaker "$@"
diff --git a/bin/kafka-preferred-replica-election.sh b/bin/kafka-preferred-replica-election.sh
index 638a92ad6e0..ac166662532 100755
--- a/bin/kafka-preferred-replica-election.sh
+++ b/bin/kafka-preferred-replica-election.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.PreferredReplicaLeaderElectionCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.PreferredReplicaLeaderElectionCommand "$@"
diff --git a/bin/kafka-producer-perf-test.sh b/bin/kafka-producer-perf-test.sh
index 73a62888a13..ce727eddf54 100755
--- a/bin/kafka-producer-perf-test.sh
+++ b/bin/kafka-producer-perf-test.sh
@@ -17,4 +17,4 @@
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh org.apache.kafka.tools.ProducerPerformance "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh org.apache.kafka.tools.ProducerPerformance "$@"
diff --git a/bin/kafka-reassign-partitions.sh b/bin/kafka-reassign-partitions.sh
index 4c7f1bc35e0..99092ff76e9 100755
--- a/bin/kafka-reassign-partitions.sh
+++ b/bin/kafka-reassign-partitions.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.ReassignPartitionsCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.ReassignPartitionsCommand "$@"
diff --git a/bin/kafka-replay-log-producer.sh b/bin/kafka-replay-log-producer.sh
index bba3241d75f..13da7fb2be7 100755
--- a/bin/kafka-replay-log-producer.sh
+++ b/bin/kafka-replay-log-producer.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.ReplayLogProducer "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.ReplayLogProducer "$@"
diff --git a/bin/kafka-replica-verification.sh b/bin/kafka-replica-verification.sh
index 4960836c0d0..fd4ab15c6c2 100755
--- a/bin/kafka-replica-verification.sh
+++ b/bin/kafka-replica-verification.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.ReplicaVerificationTool "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.ReplicaVerificationTool "$@"
diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh
index fc89f25d9d2..3225c7c9c91 100755
--- a/bin/kafka-run-class.sh
+++ b/bin/kafka-run-class.sh
@@ -45,7 +45,7 @@ should_include_file() {
fi
}
-base_dir=$(dirname $0)/..
+base_dir="$(dirname "$0")"/..
if [ -z "$SCALA_VERSION" ]; then
SCALA_VERSION=2.11.12
diff --git a/bin/kafka-server-start.sh b/bin/kafka-server-start.sh
index 5a53126172d..d8ea61a8eb6 100755
--- a/bin/kafka-server-start.sh
+++ b/bin/kafka-server-start.sh
@@ -19,7 +19,7 @@ then
echo "USAGE: $0 [-daemon] server.properties [--override property=value]*"
exit 1
fi
-base_dir=$(dirname $0)
+base_dir="$(dirname "$0")"
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
@@ -41,4 +41,4 @@ case $COMMAND in
;;
esac
-exec $base_dir/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@"
+exec "$base_dir"/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@"
diff --git a/bin/kafka-simple-consumer-shell.sh b/bin/kafka-simple-consumer-shell.sh
index 27e386ad7ee..024db53c775 100755
--- a/bin/kafka-simple-consumer-shell.sh
+++ b/bin/kafka-simple-consumer-shell.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.SimpleConsumerShell "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.SimpleConsumerShell "$@"
diff --git a/bin/kafka-streams-application-reset.sh b/bin/kafka-streams-application-reset.sh
index 33637325400..02c70487f90 100755
--- a/bin/kafka-streams-application-reset.sh
+++ b/bin/kafka-streams-application-reset.sh
@@ -18,4 +18,4 @@ if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh kafka.tools.StreamsResetter "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.tools.StreamsResetter "$@"
diff --git a/bin/kafka-topics.sh b/bin/kafka-topics.sh
index ad6a2d4d2a0..7765bc499fc 100755
--- a/bin/kafka-topics.sh
+++ b/bin/kafka-topics.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.TopicCommand "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.TopicCommand "$@"
diff --git a/bin/kafka-verifiable-consumer.sh b/bin/kafka-verifiable-consumer.sh
index 852847df03b..aee2f76fecb 100755
--- a/bin/kafka-verifiable-consumer.sh
+++ b/bin/kafka-verifiable-consumer.sh
@@ -17,4 +17,4 @@
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh org.apache.kafka.tools.VerifiableConsumer "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh org.apache.kafka.tools.VerifiableConsumer "$@"
diff --git a/bin/kafka-verifiable-producer.sh b/bin/kafka-verifiable-producer.sh
index b59bae7d2be..143ad7c87df 100755
--- a/bin/kafka-verifiable-producer.sh
+++ b/bin/kafka-verifiable-producer.sh
@@ -17,4 +17,4 @@
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
-exec $(dirname $0)/kafka-run-class.sh org.apache.kafka.tools.VerifiableProducer "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh org.apache.kafka.tools.VerifiableProducer "$@"
diff --git a/bin/trogdor.sh b/bin/trogdor.sh
index b21120932dc..82e90466acf 100755
--- a/bin/trogdor.sh
+++ b/bin/trogdor.sh
@@ -47,4 +47,4 @@ case ${action} in
esac
export INCLUDE_TEST_JARS=1
-exec $(dirname $0)/kafka-run-class.sh "${CLASS}" "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh "${CLASS}" "$@"
diff --git a/bin/zookeeper-security-migration.sh b/bin/zookeeper-security-migration.sh
index 722bde7cc4c..89d006d56f8 100755
--- a/bin/zookeeper-security-migration.sh
+++ b/bin/zookeeper-security-migration.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-exec $(dirname $0)/kafka-run-class.sh kafka.admin.ZkSecurityMigrator "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh kafka.admin.ZkSecurityMigrator "$@"
diff --git a/bin/zookeeper-server-start.sh b/bin/zookeeper-server-start.sh
index bd9c1142817..8c1d1d6fe95 100755
--- a/bin/zookeeper-server-start.sh
+++ b/bin/zookeeper-server-start.sh
@@ -19,7 +19,7 @@ then
echo "USAGE: $0 [-daemon] zookeeper.properties"
exit 1
fi
-base_dir=$(dirname $0)
+base_dir="$(dirname "$0")"
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
@@ -41,4 +41,4 @@ case $COMMAND in
;;
esac
-exec $base_dir/kafka-run-class.sh $EXTRA_ARGS org.apache.zookeeper.server.quorum.QuorumPeerMain "$@"
+exec "$base_dir"/kafka-run-class.sh $EXTRA_ARGS org.apache.zookeeper.server.quorum.QuorumPeerMain "$@"
diff --git a/bin/zookeeper-shell.sh b/bin/zookeeper-shell.sh
index 95007faeeab..df8086b5bb4 100755
--- a/bin/zookeeper-shell.sh
+++ b/bin/zookeeper-shell.sh
@@ -20,4 +20,4 @@ then
exit 1
fi
-exec $(dirname $0)/kafka-run-class.sh org.apache.zookeeper.ZooKeeperMain -server "$@"
+exec "$(dirname "$0")"/kafka-run-class.sh org.apache.zookeeper.ZooKeeperMain -server "$@"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
> The shell script should be optimized , even kafka-run-class.sh has a syntax error.
> ----------------------------------------------------------------------------------
>
> Key: KAFKA-2254
> URL: https://issues.apache.org/jira/browse/KAFKA-2254
> Project: Kafka
> Issue Type: Bug
> Components: build
> Affects Versions: 0.8.2.1
> Environment: linux
> Reporter: Bo Wang
> Assignee: Manikumar
> Priority: Major
> Labels: client-script, kafka-run-class.sh, shell-script
> Attachments: kafka-shell-script.patch
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> kafka-run-class.sh 128 line has a syntax error(missing a space):
> 127 -loggc)
> 128 if [ -z "$KAFKA_GC_LOG_OPTS"] ; then
> 129 GC_LOG_ENABLED="true"
> 130 fi
> And use the ShellCheck to check the shell scripts, the results shows some errors 、 warnings and notes:
> https://github.com/koalaman/shellcheck/wiki/SC2068
> https://github.com/koalaman/shellcheck/wiki/Sc2046
> https://github.com/koalaman/shellcheck/wiki/Sc2086
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)