-
Notifications
You must be signed in to change notification settings - Fork 49
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
docker: add script help message for macOS #5779
Conversation
35c4123
to
a00110e
Compare
I should note that I was working on a patch (but haven't finished yet) as @trws recommended in Slack that would make strip |
src/test/docker/docker-run-checks.sh
Outdated
-p, --platform=NAME Run on alternate platform (if supported)\n\ | ||
-S, --flux-security-version=N Install flux-security vers N (default=$FLUX_SECURITY_VERSION)\n | ||
-j, --jobs=N Value for make -j (default=$JOBS)\n | ||
-t, --tag TAG If checks succeed, tag image as NAME\n\ |
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!
The commit message should be updated to use the Problem:
statement form and wrapped at 72 chars.
Maybe we should move the test:
# check if running in OSX
if [[ "$(uname)" == "Darwin" ]]; then
# BSD getopt
to above where the help string is generated and make the use of =
and MacOS warning conditional on that?
Another idea would be to detect BSD getopt and suggest installing GNU getopt instead.
These are just suggestions besides the commit message changes.
Not a bad idea! I'm guessing that would work for either GNU or BSD getopt? |
Also the prefix should probably be |
4dee58e
to
f102622
Compare
My plan was to add a conditional under this line:
to strip out all of the equals signs in
I can look into making this more robust and portable in a separate PR (might need a bit of help with that). Would you review again @grondo and let me know if this help message is okay? I used I addressed the commit message changes. |
Yeah, I'd rather not see that when I run the script on Linux, or every time in our CI. Would it work to add the warning to the usage message on MacOS? |
62f5f25
to
510ecfd
Compare
@@ -27,7 +27,7 @@ die() { echo -e "$prog: $@"; exit 1; } | |||
# | |||
declare -r long_opts="help,quiet,interactive,image:,flux-security-version:,jobs:,no-cache,no-home,distcheck,tag:,build-directory:,install-only,no-poison,recheck,unit-test-only,quick-check,inception,platform:,workdir:,system" | |||
declare -r short_opts="hqIdi:S:j:t:D:Prup:" | |||
declare -r usage=" |
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 commit message should indicate the problem is only obvserved on MacOS.
src/test/docker/docker-run-checks.sh
Outdated
export EXTRA_MACOS_STUFF="\n\ | ||
You are using BSD getopt on macOS. If you have gnu-getopt in your PATH, \n\ | ||
force the script to use that by setting FORCE_GNU_GETOPT=1.\n" | ||
declare usage=${usage}${EXTRA_MACOS_STUFF} |
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 don't think you need to use declare
again here since usage
has already been declared. In fact, if this were in a function it might declare usage
as local
and the modifications would be lost, so I would remove use of declare
here.
Also, I thought this issue was about BSD getopt not supporting =
. Should that be mentioned in the extra help message? i.e. something like "either avoid using '=' between options and values or force the use of GNU getopt with FORCE_GNU_GETOPT=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.
"either avoid using '=' between options and values
This message isn't necessary with the proposed changes which strip out all =
in the GETOPT
variable (line 65) which is effectively all =
signs before the --
. I can add it if you still want it but I just wanted to make sure you didn't miss line 65:
GETOPTS=`getopt $short_opts -- $(echo $* | sed "s/=/ /g")`
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.
So I guess this PR title needs to be updated because it's not just a help message change anymore.
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.
Oh, and the commit message too. Whoops.
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 ignore (basically) everything I said above. This should be addressed now.
20f61f8
to
35ce0e8
Compare
Ok, this is the behavior now when an equals sign w/ an option is passed to the script on macOS:
or this:
|
src/test/docker/docker-run-checks.sh
Outdated
export EXTRA_MACOS_STUFF="\n\ | ||
You are using BSD getopt on macOS. BSD getopt does not recognize '='\n\ | ||
between options. Use a space instead. If gnu-getopt is first in your\n\ | ||
PATH, force the script to use that by setting FORCE_GNU_GETOPT=1.\n" | ||
usage=${usage}${EXTRA_MACOS_STUFF} |
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.
It shouldn't be necessary to use export
here since EXTRA_MACOS_STUFF
does not need to be exported to the environment of future commands. How about just:
usage="${usage}\n\
You are using BSD getopt on macOS. BSD getopt does not recognize '='\n\
between options. Use a space instead. If gnu-getopt is first in your\n\
PATH, force the script to use that by setting FORCE_GNU_GETOPT=1.\n"
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.
Good catch @grondo, fixed.
35ce0e8
to
e765692
Compare
Problem: recently, several core developers have noted that the docker-run-checks.sh script borks when command-line options that specify values do so with an equals sign rather than a space on macOS. Add a help message to show up on macOS reminding devs to strip all '=' and replace them with spaces in their command-line arguments if BSD getopt is used. Also, give users the option to set an environment variable to tell the script on macOS that it should assume GNU getopt is being used ('FORCE_GNU_GETOPT=1').
e765692
to
3d19d99
Compare
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.
Looks great! Thanks!
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #5779 +/- ##
==========================================
- Coverage 83.30% 83.28% -0.02%
==========================================
Files 514 514
Lines 82774 82774
==========================================
- Hits 68955 68941 -14
- Misses 13819 13833 +14 |
Recently, several core developers have noted that the docker-run-checks.sh script borks when command-line options that specify values do so with an equals sign rather than a space. Since this is not super intuitive, update the usage/help message for that script accordingly.
I pulled out all the = signs from the usage message and added a note, but maybe one or the other is more desirable.