-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add macOS support to build script #14
Conversation
Thanks for your contribution. I don't like
A very common misuse (which I find very annoying) is constructs like;
|
Ok, how would you like me to proceed?
…On Mon, 14 Mar 2022, 17:08 Lars Ekman, ***@***.***> wrote:
Thanks for your contribution.
I don't like [ in scripts. Unix shell scripts are closer to a functional
language regarding conditionals and using [ (which is a built-in alias
for test) encourage the imperative programming style. Note for instance
that the man page doesn't mention "condition" or "expresstion" when
describing if (from man bash);
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
A very common misuse (which I find very annoying) is constructs like;
grep -q pattern some/file
if [ $? -eq 0 ]; then
echo "Found"
...
—
Reply to this email directly, view it on GitHub
<#14 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC4U5PGHRS66V5XNE7RIEDU73JW3ANCNFSM5QUCCHIA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Make the suggested upates, squash and force-push. |
Perhaps I'm not as smart as you, because I don't understand what your suggested updates are. I understand you "don't like |
build.sh
Outdated
dir=$(dirname $0) | ||
if [ "$(uname)" = Darwin ] ; then | ||
if [ -s "$dir" ]; then | ||
dir=$(stat -f%Y "$0") | ||
fi | ||
else | ||
dir=$(readlink -f "$dir") | ||
fi |
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.
Please remove the [
and replace with test
. Like;
if test "$(uname)" = Darwin ; then
test -s "$dir" && dir=$(stat -f%Y "$0")
else
dir=$(readlink -f "$dir")
fi
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.
Maybe better to use the safer;
if uname | grep -qi Darwin ; then
...
This illustrates my aversion to [
, one tend to forget that the "thing" after if
is not an expression.
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.
done
build.sh
Outdated
if [ "$(uname)" = Darwin ] ; then | ||
log "Not stripping image/kahttp: not supported on macOS" | ||
else | ||
strip image/kahttp | ||
fi |
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.
Replace with;
test "$(uname)" != Darwin && strip image/kahttp
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.
Same as above;
uname | grep -qi darwin || strip image/kahttp
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.
done
My bad, sorry. I had started a review and made suggestions but was unaware that the suggestion was not visible to you unless I press a (somewhat hidden) "Submit" button. I hope you see them now. |
And my apologize again for answer in #14 (comment). I thought my suggestions were visible. |
macOS bundles BSD readlink, which doesn't support -f (or any equivalent). Instead, use stat (again, the BSD version) as a partial replacement -- it will canonicalise symlinks. You also can't strip ELF binaries on macOS, since the bundled strip only supports Mach-O format.
2307efd
to
a3231e7
Compare
All good. Updated as requested. |
macOS bundles BSD readlink, which doesn't support -f (or any
equivalent). Instead, use stat (again, the BSD version) as a partial
replacement -- it will canonicalise symlinks.
You also can't strip ELF binaries on macOS, since the bundled strip only
supports Mach-O format.