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

shell script should be sh and not bash #5819

Open
sylware opened this issue Oct 7, 2018 · 2 comments
Open

shell script should be sh and not bash #5819

sylware opened this issue Oct 7, 2018 · 2 comments

Comments

@sylware
Copy link

sylware commented Oct 7, 2018

Scripts should expect only basic sh on a system and not bash.
If you want to use the complex sh extensions of bash, do not hesitate to provide your binary of bash in the package (even a statically linked build will do).
The same apply to python scripts... or "any" scripts (python may dynamically load system libs in order to "script" them, then statically linked python interpreter won't do on gnu libc systems, only a dynamically linked one will work)

@illwieckz
Copy link

illwieckz commented Oct 8, 2018

It's not a problem to set bash as a dependency. If no one is able to build and distribute bash for your system you have no more chance to run steam in any way.

Just as an example, it's good to rely on advanced things like nestable subshell, you know how it's far better and safer to have to write:

echo $(echo $(echo $(echo hello world)))

than to write:

echo `echo \`echo \\\`echo hello world\\\`\``

and other “basic shell” legacies.

You already use the nestable subshells, please don't switch to not-nestable backquotes (code from steam.sh):

STEAMROOT="$(cd $(dirname $0) && echo $PWD)"

By the way that piece of code is very ugly, you don't need to rely on a directory pivot to do this, even if the subshell somewhat secures it. And that's not the only thing that is asking for trouble: I just checked this lone line in an obvious known-to-broke use case, and I confirm you this code is unsafe and is not reliable at all. That lone line is broken by itself.

Please do not delete my homedir anymore because of poorly written shell scripts. Bash is still an unsafe scripting language, but it allows some better methodology (like the one above) to do less mistakes. That issue was not reported by me but I faced a variant of it, and yes it deleted my whole homedir, hopefully I never ran steam outside of a chroot because I never trusted it.

Oh and make sure everyone use shellcheck.

It's OK to set bash as a dependency.

Note: I can help you make better linux things (I remember you this other thread).

@sylware
Copy link
Author

sylware commented Oct 8, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants