Skip to content

Commit d6d99e5

Browse files
author
E.S. Rosenberg a.k.a. Keeper of the Keys
committed
Added check for sed return code, switched to bash and also properly inserts newlines on Linux.
1 parent 90c2691 commit d6d99e5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugins/convert_README_to_header.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# A simple script to build a C++ header file containing the plugin description
44
# from the plugin's README.md
@@ -30,8 +30,14 @@ outfilename=`basename $outfile`;
3030
# See http://stackoverflow.com/a/16576291
3131
# On Mac OS's sed, \n is not recognized as a newline character, but
3232
# \[actual newline] works
33-
desc=`sed -e ':a' -e 'N' -e '$!ba' -e 's/\"/\\\"/g' -e 's/\n/\\\\n"\\
34-
"/g' "$path/README.md"`;
33+
desc=`sed -e ':a' -e 'N' -e '$!ba' -e 's/\\\/\\\\\\\/g' -e 's/\"/\\\"/g'\
34+
-e 's/\n/\\\\n\"\
35+
\"/g' "$path/README.md"`;
36+
37+
if (( $? != 0 )); then
38+
echo 'Sed failed to generate $desc'
39+
exit 1
40+
fi
3541

3642
identifier=`echo "PLUGINS_${plugin}_${outfilename%.h}_H_" | tr '[:lower:]' '[:upper:]'`
3743

0 commit comments

Comments
 (0)