-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Adds detection of BusyBox v1.30.0+ with updated timeout arguments #81
base: master
Are you sure you want to change the base?
Conversation
Busybox updated timeout's flags to match coreutils. This broke the script that was specifically dealing with BusyBox being different from coreutils. To fix the problem without breaking support for older versions of busy box, this a version check of busybox to determine which version of the flags to use. Note, the changes use bash's regular expression's BASH_REMATCH to get the job done. For Alpine users, this means you'll have to install bash and execute wait-for-it using bash.
else | ||
WAITFORIT_ISBUSY=0 | ||
WAITFORIT_BUSYTIMEFLAG="" | ||
# see if timeout.c args have been updated in busybox v1.30.0 or newer |
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.
Why not just read timeout --version
?
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 possible. It's just that timeout, at least on busybox, doesn't have a --version flag.
timeout --version
unrecognized option `--version'
BusyBox v1.22.1 (2015-03-20 11:09:37 GMT) multi-call binary.`
However, it does output the busybox version info in the error, so it could still be used.
It was just a judgment call to use busybox itself to gather the version info since relying on timeout error output felt slightly worse.
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.
well, that's a great reason. Looks good to me, 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 do not get what is expected by "timeout.c" (".c")
Is it a misprint?
Great thank you! |
# see if timeout.c args have been updated in busybox v1.30.0 or newer | ||
# note: this requires the use of bash on Alpine | ||
if [[ $WAITFORIT_ISBUSY && $(busybox | head -1) =~ ^.*v([[:digit:]]+)\.([[:digit:]]+)\..+$ ]]; then | ||
if [[ ${BASH_REMATCH[1]} -le 1 && ${BASH_REMATCH[2]} -lt 30 ]]; 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.
This simplified version comparison looks not good since it can detect BusyBox 0.60 as new version.
However BusyBox 1.0.0-pre1 was release in 2003. It is unlikely somebody will use it in 2020 with latest wait-for-it.sh
https://busybox.net/oldnews.html
And for future versions of BusyBox this code will work OK.
WAITFORIT_ISBUSY=0 | ||
WAITFORIT_BUSYTIMEFLAG="" | ||
# see if timeout.c args have been updated in busybox v1.30.0 or newer | ||
# note: this requires the use of bash on Alpine |
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.
As far as I know wait-for-it.sh already needs bash in Alpine.
So there is no need to state this here additionally and frighten reviewers.
This works and is backwards compatible, but it breaks the current tests that got merged into upstream after this was made |
This fixes #71 - adds support for BusyBox 1.30.0+ and maintains support for versions below.
The problem
BusyBox below v1.30.0 had a non-standard implementation of
timeout
. BusyBox v1.30.0+ updatedtimeout
to match coreutils. This library was previously checking if timeout belongs to busybox and assuming it uses the non-standard flags.To fix the problem without breaking support for older versions of BusyBox, this adds a version check of BusyBox to determine which version of the flags to use.
Note: the changes use bash's regular expression's
BASH_REMATCH
to get the job done. For Alpine users, this means you'll have to install bash and execute wait-for-it using bash.The last time I contributed to wait-for-it, it was not compatible with
ash
, but things may have changed. If requiring bash is a problem, just say so.I've only tested on Alpine 3.1 and 3.10 w/ bash, but welcome additional testing and feedback.
Fixes #71