Copilot commented on code in PR #20272:
URL: https://github.com/apache/druid/pull/20272#discussion_r3949057397


##########
distribution/docker/druid.sh:
##########
@@ -102,8 +102,8 @@ setKey() {
     # Delete from all
     sed -ri "/$key=/d" $COMMON_CONF_DIR/common.runtime.properties
     [ -f $service_conf ] && sed -ri "/$key=/d" $service_conf
-    [ -f $service_conf ] && echo -e "\n$key=$value" >>$service_conf
-    [ -f $service_conf ] || echo -e "\n$key=$value" 
>>$COMMON_CONF_DIR/common.runtime.properties
+    [ -f $service_conf ] && printf '\n%s=%s\n' "$key" "$value" >>$service_conf
+    [ -f $service_conf ] || printf '\n%s=%s\n' "$key" "$value" 
>>$COMMON_CONF_DIR/common.runtime.properties

Review Comment:
   Same quoting issue as in `peon.sh`: the `-f` test and especially the 
redirection destinations are unquoted. Quoting `"$service_conf"` and the 
`>>"..."` targets avoids word-splitting/globbing problems and makes the script 
more resilient to unexpected paths.



##########
distribution/docker/peon.sh:
##########
@@ -80,8 +80,8 @@ setKey() {
     # Delete from all
     sed -ri "/$key=/d" $COMMON_CONF_DIR/common.runtime.properties
     [ -f $service_conf ] && sed -ri "/$key=/d" $service_conf
-    [ -f $service_conf ] && echo -e "\n$key=$value" >>$service_conf
-    [ -f $service_conf ] || echo -e "\n$key=$value" 
>>$COMMON_CONF_DIR/common.runtime.properties
+    [ -f $service_conf ] && printf '\n%s=%s\n' "$key" "$value" >>$service_conf
+    [ -f $service_conf ] || printf '\n%s=%s\n' "$key" "$value" 
>>$COMMON_CONF_DIR/common.runtime.properties

Review Comment:
   Redirection targets are unquoted here (`>>$service_conf`, 
`>>$COMMON_CONF_DIR/...`). If either path ever contains whitespace or glob 
characters, this can break or redirect unexpectedly. Quote the redirection 
paths (and, ideally, also quote `$service_conf` in the `-f` test for 
consistency) to make the write robust.



-- 
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