[btls] Fix bashism in create-object-library.sh
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sun, 2 Oct 2016 15:12:45 +0000 (17:12 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Sun, 2 Oct 2016 15:12:45 +0000 (17:12 +0200)
Found by checkbashisms(1) as "unsafe echo with backslash". Some shells don't expand embedded \n in a string by default,
which broke the build on systems like ArchLinux or Alpine where /bin/sh points to those shells because the generated .lo
file contained just a single line instead of two.

Thanks to @JustArchi for researching this on the Mono Gitter channel, it made fixing the issue a lot easier!

mono/btls/create-object-library.sh

index 94da6b33f5e6f0b992c36efb5415a563a58ceb20..8ceda08a77519439bd335476a2baaa6d4f134b02 100755 (executable)
@@ -19,10 +19,11 @@ while [ "$1" != "--" ]; do
        file=$1; shift
        filename=`basename $file`
        LOFILE=$file.lo
+       echo "$HEADER" > $LOFILE
        if [ "$STATIC" = "static" ]; then
-               echo "$HEADER\nnon_pic_object='$filename'" > $LOFILE
+               echo "non_pic_object='$filename'" >> $LOFILE
        else
-               echo "$HEADER\npic_object='$filename'" > $LOFILE
+               echo "pic_object='$filename'" >> $LOFILE
        fi
        echo "$DIR/$file " >> $FILELIST
        echo "$DIR/$LOFILE " >> $LOFILELIST