-
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
base: master
Are you sure you want to change the base?
Changes from all commits
d6d99e5
aa27b81
18ac8ce
0516f69
b01e907
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| #!/bin/sh | ||
| #!/bin/bash | ||
|
|
||
| # A simple script to build a C++ header file containing the plugin description | ||
| # from the plugin's README.md | ||
| # The output file then contains one variable 'plugin_description'. | ||
|
|
||
| set -e | ||
|
|
||
| if [ $# != 2 ]; then | ||
| echo "Usage: convert_README_to_header.sh <plugin path> <outfile path>"; | ||
| echo "<plugin path>: path to plugin dir, e.g. plugins/artnet"; | ||
|
|
@@ -30,8 +32,9 @@ outfilename=`basename $outfile`; | |
| # See http://stackoverflow.com/a/16576291 | ||
| # On Mac OS's sed, \n is not recognized as a newline character, but | ||
| # \[actual newline] works | ||
| desc=`sed -e ':a' -e 'N' -e '$!ba' -e 's/\"/\\\"/g' -e 's/\n/\\\\n"\\ | ||
| "/g' "$path/README.md"`; | ||
| desc=`sed -e ':a' -e 'N' -e '$!ba' -e 's/\\\/\\\\\\\/g' -e 's/\"/\\\"/g' \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're escaping backslash:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We'll need one per sed backslash (escaping or real), rather than one in total.
Likewise here. I believe you're trying to logically replace
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes because backslash also has significance in C into which the readme is ultimately converted. |
||
| -e 's/\n/\\\\n\"\\ | ||
| \"/g' "$path/README.md"`; | ||
|
|
||
| identifier=`echo "PLUGINS_${plugin}_${outfilename%.h}_H_" | tr '[:lower:]' '[:upper:]'` | ||
Keeper-of-the-Keys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
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.