-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
test: update add_vagrant_box.sh #15831
Conversation
if [[ ! -f $box_dir$box/metadata_url ]] ; then | ||
printf "https://vagrantcloud.com/cilium/$box" > $box_dir$box/metadata_url | ||
echo "https://vagrantcloud.com/cilium/$box" > "$box_dir$box/metadata_url" |
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.
Could you please elaborate on this change? Asking because I was under the impression that printf
was more portable than echo
. Or is it because you just want a newline character at the end of the file?
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.
Ah, good catch with the newline. I initially switched away from printf
as there were no arguments being passed, and correction functionality required $box
to not contain any printf verbs (e.g. if $box
was foo%s
then printf
would fail, of course this would not likely happen in practice).
The relevant ShellCheck is SC3037, which indeed warns that flags to echo
are undefined in POSIX sh
. However, this script explicitly uses /bin/bash
, and -n
is defined there.
Result: I've added a -n
to echo
.
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.
Ok, I was just wondering why the switch. I understand the %s
reason. Thanks!
I don't think the newline matters at all, and I think we'd be as well without this -n
option. It's true we enforce bash so we should have it, but it's just not clear when reading the script what we need to omit the new line (I suspect printf
didn't add it just because nobody cared to add it). But that's a minor details anyway, so feel free to revert the -n
or to keep it :).
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.
Vagrant itself seems to omit the trailing newline, so let's keep the -n
.
This commit fixes a few portability issues and minor bugs, mainly caught by ShellCheck. Signed-off-by: Tom Payne <tom@isovalent.com>
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 pending Quentin's comment
test-me-please |
This script is not used in CI tests. |
Ah, thanks. I saw references to it in several Jenkinsfiles:
but see now that these are in fact provisioned as part of the Packet Terraform scripts. |
We should really move this script to |
-> #15859 |
This commit fixes a few portability issues and minor bugs, mainly caught
by ShellCheck.