op.sh: fix arg quoting so special chars survive eval (#37967)

op.sh: don't eval CMD, run argv directly so special chars work

Previously op_run_command joined "$@" into a single string and eval'd
it, which broke on inputs containing shell metacharacters. For example,
'op esim --download "LPA:1$[rsp.truphone.com]($url)$QRF-SPEEDTEST" name'
would fail with a syntax error on the unquoted parens. Run "$@" instead
and only use $* for the printed display string. Also quote the unquoted
$@ in the other op_run_command callers.
This commit is contained in:
Trey Moen
2026-06-09 11:44:57 -07:00
committed by GitHub
parent 7abe0205fd
commit 57b5eb3113
+10 -10
View File
@@ -48,7 +48,7 @@ function retry() {
}
function op_run_command() {
CMD="$@"
CMD="$*"
echo -e "${BOLD}Running command →${NC} $CMD"
for ((i=0; i<$((19 + ${#CMD})); i++)); do
@@ -57,7 +57,7 @@ function op_run_command() {
echo -e "┘\n"
if [[ -z "$DRY" ]]; then
eval "$CMD"
"$@"
fi
}
@@ -310,33 +310,33 @@ function op_build() {
op_run_command system/manager/build.py
else
# scons is fine on PC
op_run_command scons $@
op_run_command scons "$@"
fi
}
function op_juggle() {
op_before_cmd
op_run_command tools/plotjuggler/juggle.py $@
op_run_command tools/plotjuggler/juggle.py "$@"
}
function op_lint() {
op_before_cmd
op_run_command scripts/lint/lint.sh $@
op_run_command scripts/lint/lint.sh "$@"
}
function op_test() {
op_before_cmd
op_run_command pytest $@
op_run_command pytest "$@"
}
function op_replay() {
op_before_cmd
op_run_command tools/replay/replay $@
op_run_command tools/replay/replay "$@"
}
function op_cabana() {
op_before_cmd
op_run_command tools/cabana/cabana $@
op_run_command tools/cabana/cabana "$@"
}
function op_sim() {
@@ -347,7 +347,7 @@ function op_sim() {
function op_clip() {
op_before_cmd
op_run_command tools/clip/run.py $@
op_run_command tools/clip/run.py "$@"
}
function op_switch() {
@@ -489,4 +489,4 @@ function _op() {
esac
}
_op $@
_op "$@"