Skip to content
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

No longer rely on the presence of bash #605

Closed
wants to merge 1 commit into from
Closed

No longer rely on the presence of bash #605

wants to merge 1 commit into from

Conversation

ngaro
Copy link

@ngaro ngaro commented Feb 27, 2021

Although bash is available in most distributions, this is not always the case.
A notable example are docker containers based on Alpine linux it's more often missing than present.
This PR makes sure it works everywhere by relying on a shell instead of a specific shell.

The FHS defines that if the system has shells (1 or more), at least one of them should be in /bin. So the forced location is not a problem.

The script itself doesn't need any change, it always does exactly the same. It doesn't matter if you use bash, zsh, csh or even busybox.

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [[ below is not part of POSIX (https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_04) and should be changed too IHMO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this in in #606

Copy link
Contributor

@rusty-snake rusty-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional (to be full POSIX /bin/sh compliant):

-[[ $(id -u -n) != "root" ]]
+[ "$(id -u -n)" != "root" ]

@funilrys
Copy link
Member

funilrys commented May 2, 2021

I will merge this first, then #608. Therefore, it shouldn't be a problem. Or did I miss something?

Thank you for the feedback!

@ngaro ngaro closed this Jan 16, 2022
@ngaro ngaro deleted the portable_shell branch January 16, 2022 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants