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

Rewrite all bash-specific code to be POSIX shell compatible #77

Closed
tpimh opened this issue Nov 7, 2017 · 7 comments
Closed

Rewrite all bash-specific code to be POSIX shell compatible #77

tpimh opened this issue Nov 7, 2017 · 7 comments

Comments

@tpimh
Copy link

tpimh commented Nov 7, 2017

Most systems have bash installed, so that is not an issue for them, but some lack it. I suggest changing default interpreter of scripts/*.sh and tests/*.test from /bin/bash to /bin/sh and checking that they run fine with dash which is the closest to full POSIX shell implementation. I'm not proposing any changes yet, I'm just starting a discussion here (or maybe it should be reposted to the mailing list?)

@landley
Copy link
Owner

landley commented Nov 9, 2017 via email

@tpimh
Copy link
Author

tpimh commented Nov 9, 2017

In my opinion both toysh and the scripts should be improved. And both should be made POSIX compatible. Implementing support for bashisms in toysh may be a very time consuming task that will result in bloating. I think it is reasonable to only implement POSIX standard in toysh and check that all the scripts comply with this standard. I know that there are some bashisms used in those scripts, but I doubt that it would be easier to support them in toysh than rewrite to something simpler to implement. Doesn't seem counterproductive at all to me.

@the-real-neil
Copy link

I'd like to voice my strong support for build/test scripts that require only a POSIX compliant shell. That toysh aspires to become bash-like isn't my personal preference, but this aspiration seems mostly divorced from what happens in the scripts that build and test this project.

@technosaurus
Copy link

The toybox shell is intended to be a reasonable bash replacement, so
rather than remove bashisms from our shell code the plan is to implement
support in toysh. That hasn't been done yet, but modifying toybox's shell
code to run in something other than toysh seems counterproductive.

If you actually look at the code, 99% is already sh compliant.
Aside from the shebang, the only thing that stands out as a gratuitous bashism is this line in runtest.sh:

[ "${i:0:1}" == "/" ] || i=$(which $i)`

and it could be replaced by

case "$i" in
/*);;
*) i=$(which $i);;
esac

I personally don't care that toybox requires a GPL licensed package to build, nor that bash is slower and slower with each version, nor that the only standard applicable to bash is Posix sh - with a bunch of unspecified addons that vary between versions, yet has no versioning standard for the shebang (Hell even perl and php do better). ...but even autotools can make their scripts Posix compliant.

@landley
Copy link
Owner

landley commented Nov 23, 2017 via email

@FSMaxB
Copy link

FSMaxB commented Nov 23, 2017

I'm having trouble understanding the situation: Are those scripts required in order to build toybox, or at least toybox' shell implementation? If so, there is a hen and egg problem that could only be solved by using bash, if the bashism are not removed.

@landley
Copy link
Owner

landley commented Nov 24, 2017 via email

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

No branches or pull requests

6 participants