-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove empty arguments from launcher #1650
fix: remove empty arguments from launcher #1650
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Can you also add a test case until internal/node/test
that fails without this fix so we prevent regression in the future?
internal/node/launcher.sh
Outdated
@@ -224,13 +224,28 @@ if [ "${EXPECTED_EXIT_CODE}" -eq "0" ]; then | |||
# handled by the node process. | |||
# If we had merely forked a child process here, we'd be responsible | |||
# for forwarding those OS interactions. | |||
exec "${node}" "${LAUNCHER_NODE_OPTIONS[@]:-}" "${USER_NODE_OPTIONS[@]:-}" "${MAIN}" "${ARGS[@]:-}" | |||
if (( ${#ARGS[@]} )); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if (( ${#ARGS} )); then
is equivalent and sufficient here.
The duplication is not great. How about something like:
command="${node}" "${LAUNCHER_NODE_OPTIONS[@]:-}" "${USER_NODE_OPTIONS[@]:-}" "${MAIN}"
# If there are no arguments we skip the arguments because some programs
# such as grpc_tools_node_protoc_plugin in the grpc-tools do not handle empty arguments well
if (( ${#ARGS} )); then
command="${command}" "${ARGS[@]:-}"
fi
exec "${command}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a issue with using set -u
and empty arrays with older versions of bash.
See more information here: https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u
@gregmagolan Added a test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for simplification & adding the regression test.
Will green up that flake and merge.
@@ -224,12 +224,12 @@ if [ "${EXPECTED_EXIT_CODE}" -eq "0" ]; then | |||
# handled by the node process. | |||
# If we had merely forked a child process here, we'd be responsible | |||
# for forwarding those OS interactions. | |||
exec "${node}" "${LAUNCHER_NODE_OPTIONS[@]:-}" "${USER_NODE_OPTIONS[@]:-}" "${MAIN}" "${ARGS[@]:-}" | |||
exec "${node}" "${LAUNCHER_NODE_OPTIONS[@]:-}" "${USER_NODE_OPTIONS[@]:-}" "${MAIN}" ${ARGS[@]+"${ARGS[@]}"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's neat 👍 👍
name = "binary_with_no_arguments", | ||
data = ["empty_args_fail.js"], | ||
entry_point = "empty_args_fail.js", | ||
expected_exit_code = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: expected_exit_code = 0
is redundant
|
||
if (theArgs.length != 0) { | ||
// Non-zero exit code if the argument list is not empty | ||
process.exit(42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of the error code
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently the launcher script adds a empty argument to the end of all invocations.
Some programs do not like it and fail. An example is
grpc_tools_node_protoc_plugin
in thegrpc-tools
NPM package.What is the new behavior?
If the argument list is empty we don't add an empty argument when invoking programs
Does this PR introduce a breaking change?