-
Notifications
You must be signed in to change notification settings - Fork 221
Added check for sed return code, switched to bash and also properly i… #1593
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
Open
Keeper-of-the-Keys
wants to merge
5
commits into
OpenLightingProject:master
Choose a base branch
from
Keeper-of-the-Keys:convert-readme-newlines
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d6d99e5
Added check for sed return code, switched to bash and also properly i…
aa27b81
Added space
18ac8ce
Added set -e at suggestion of @FloEdelmann
0516f69
Removed conditional that was obsoleted by sed -e
b01e907
Merge branch 'master' into convert-readme-newlines
peternewman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 per the discussion in the issue, this needs reverting as it won't work on FreeBSD:
https://www.freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/shells.html
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.
bash is not the default shell but it is available, whether installed or not is a different story but we can and should make it a dependency.
grep -R '#! /bin/bash' . | wc -lreturns 41 on the OLA source directory so saying we depend on bash is reasonable if not necessary.In addition to that /bin/sh causes a crapshoot of unpredictable shell interpreters where each distro is running it through whatever sh-like solution they happen to like and stuff works or doesn't work while bash is bash is bash (except maybe for version stuff but unless we use some cutting edge bash feature we're not likely to run into that).
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.
And
grep -R '#!/bin/bash' . | wc -lreturns 9There 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? If you've tried to install OLA on say Windows, adding even more dependencies just makes it even harder, likewise it's more slightly different versions of stuff to support, it's taken us long enough to get most stuff compiling across Linux, OS X, *BSD and Windows. TBH if we were going to do anything, adding perl would probably be the sensible choice, as it's standardised, has been around forever so is well deployed and would also fix these sed incompatibilities.
Try running that again in a clean checkout, you'll find all those ones with spaces are from Makefile magic; I don't know what it does if you don't have bash, but there would be an option to do some magic.
It's really not that hard, there are even tools to help:
https://wiki.ubuntu.com/DashAsBinSh
https://linux.die.net/man/1/checkbashisms
So these are the actual ones we'd need to look at, GitHub finds 7:
https://github.com/OpenLightingProject/ola/search?q=%22%2Fbin%2Fbash%22&unscoped_q=%22%2Fbin%2Fbash%22
So the ones in include/ are the ones actually run automatically during the build. I was about to have to agree with you, then I looked a bit more carefully:
ola/include/ola/Makefile.mk
Line 48 in d101097
I'm no expert, but I'm fairly confident that means it runs it via
shand will therefore actually use your sh interpreter rather than whatever is in the shebang line. So we should probably remove that bug in the files by changing /bin/bash to /bin/sh, but its probably having no impact to the build.Uh oh!
There was an error while loading. Please reload this page.
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.
If bash was some exotic shell that was not in wide use I would absolutely agree with you, however bash is actually very well established to the point that it is even available for windows iirc, it may not be an ISO standard but bash X.Y on OS A will behave the same and bash X.Y on OS B (and I think this may in general even apply for X.y and X.z)
This script that we are currently discussing is a live example of /bin/sh not behaving the same across different platforms while on OSX it was doing what you expected it to do it was not doing so on Debian based distros that use dash for sh and this script was not doing anything crazy complicated but the different globbing/parsing behaviors of the different sh implementations killed consistent results.
I think we have better things to do with our time bash is easily installed and widely available.
Also note that according to the documentation about installing on Windows bash is the actual shell used there through mingw (though the MSYS part of mingw seems to be dead so that may not be wise, but an alternative is out there - MSYS2 ) and MS has released a "Linux on windows" environment this year which seems to obviate the need for mingw.
https://wiki.openlighting.org/index.php/Building_OLA_for_Windows
https://www.msys2.org/
https://itsfoss.com/install-bash-on-windows/
Both MSYS and MSYS2 provide bash shells as does "Linux on Windows", FreeBSD may not ship with it but it's installable with ease
As far as I know you are correct.