pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[fix] Reapply shell script parameter passthrough fix #22867 reverted in #22921

Open lhotari opened this issue 1 year ago • 1 comments

This reverts commit fa745384c2c3ea8c16e6c0cd078328a653fa3073.

Motivation

#22921 reverted the change in #22867 to use correct way of passing parameters in shell scripts. The correct syntax is "$@".

In #22921, the argumentation was that a command bin/pulsar zookeeper-shell --run-once "ls /ledgers" no longer works. This type of command has always been invalid for 2 reasons:

  • bin/pulsar zookeeper-shell has never supported --run-once parameter.
    • there's a Python based zk-shell which supports this syntax. bin/pulsar zookeeper-shell doesn't use zk-shell under the covers.
  • bin/pulsar zookeeper-shell has never supported quoting the arguments to the command. This happened to work because of invalid parameter passing which is fixed by #22867
    • The Python based zk-shell requires the --run-once "ls /path" syntax. bin/pulsar zookeeper-shell doesn't use zk-shell under the covers.

Modifications

  • revert commit fa745384c2c3ea8c16e6c0cd078328a653fa3073 / PR #22921

Documentation

  • [ ] doc
  • [ ] doc-required
  • [x] doc-not-needed
  • [ ] doc-complete

lhotari avatar Jun 17 '24 10:06 lhotari

I hope we get the scripts fixed, at least for master branch. It's clearly a problem to use $@ without double quotes to pass parameters on to another command. That's why I think that this change should be made "$@".

lhotari avatar Jun 25 '24 05:06 lhotari

$@
When you use $@ without quotes, it expands to each positional parameter as a separate word. This means that if any of the arguments contain spaces, they will be split into multiple words. For example, if a script is run with the arguments one two and three, $@ would treat them as three separate arguments: one, two, and three.
"$@"
When you use "$@" with double quotes, it expands to each positional parameter preserved as a single word, regardless of spaces. This means that each argument is treated exactly as it was passed, including spaces. For example, if a script is run with the arguments “one two“ and three, "$@" would treat them as two arguments: ”one two“ and three.

Technoboy- avatar Oct 09 '24 13:10 Technoboy-

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.32%. Comparing base (bbc6224) to head (28a69ee). Report is 653 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #22923      +/-   ##
============================================
+ Coverage     73.57%   74.32%   +0.75%     
- Complexity    32624    34350    +1726     
============================================
  Files          1877     1949      +72     
  Lines        139502   146867    +7365     
  Branches      15299    16168     +869     
============================================
+ Hits         102638   109160    +6522     
- Misses        28908    29284     +376     
- Partials       7956     8423     +467     
Flag Coverage Δ
inttests 27.54% <ø> (+2.95%) :arrow_up:
systests 24.44% <ø> (+0.12%) :arrow_up:
unittests 73.67% <ø> (+0.82%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

see 621 files with indirect coverage changes

codecov-commenter avatar Oct 09 '24 17:10 codecov-commenter