-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tools: remove bashisms from release script #36123
Conversation
b14fde0
to
2f9d621
Compare
@aduh95 note that shells are weird (feel free to ignore if you already know all this):
Personally I would avoid bash for pretty much anything and rewrite this code in Node or Python ^^ |
@codebytere may I ask you to use next week release as a test for those changes? I mean, if the code does look good to you of course. |
@nodejs/build just a heads up if anyone wants to review or block this before it lands, otherwise I'm planning to merge this later this week. |
tools/release.sh
Outdated
fi | ||
fi | ||
keynum= | ||
while [ -z "${keynum##*[!0-9]*}" ] || [ "$keynum" -le 0 ] || [ "$keynum" -gt "$keycount" ]; do |
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.
Are integer expressions posix?
If they are (I think so) - this [ -z "${keynum##*[!0-9]*}" ] || [ "$keynum" -le 0 ] || [ "$keynum" -gt "$keycount" ]
can probably be ((keynum > keycount))
(since keycount is known to be an int)
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.
Hum are you sure? If keynum
is not a number, it won't be true:
$ keycount = 3
$ keynum="test"
$ (( keynum > keycount )) && echo "true"
$ (( keynum > keycount )) || echo "false"
false
Also we have to take in consideration the case where the user provides 0
(the numbering starts at 1
).
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.
Then probably just the first two bits can be ((keynum > 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.
The issue is that the behaviour is kind of surprising if keynum
is not digits-only:
$ sh -c "keynum=;((keynum > 0)) || echo 'false'" # false, as expected
false
$ sh -c "keynum=1;((keynum > 0)) || echo 'false'" # true, as expected
$ sh -c "keynum="12d";((keynum > 0)) || echo 'false'" # false, but prints a warning to stderr
sh: ((: 12d: value too great for base (error token is "12d")
false
$ sh -c "keynum="0xa";((keynum > 0)) || echo 'false'" # true, expected false
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR-URL: nodejs#36123 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
defaf0d
to
1729ba7
Compare
Landed in 1729ba7 |
PR-URL: #36123 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#36123 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
I think this PR has introduced some problems with the I run the script with
I'll possibly open a revert PR prior to the next releases going out, but will hold off in case there's a quick/easy fix. /cc @nodejs/releasers |
+1 to revert. I've tried to look over 1729ba7 for obvious problems but it's far too heavy-handed for the brainpower I have available for this. This whole "remove bashisms" is silliness IMO and is primarily an exercise in introducing churn and risk (stability, security, and other) because the nature of Bash is to be obscure when terse, which you can see on display in 1729ba7. |
PR-URL: #36123 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
In preparation for #36099.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes