diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-04 21:46:18 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-05 21:26:37 +0200 |
commit | 8b856bd5a12f0d9edbdea60916900fd3f7f40823 (patch) | |
tree | 068b5a6d15bfa756e7a57ca0642ecff02f369111 | |
parent | f558a44610019ca2149ed6e161992ad20f1a9419 (diff) | |
download | serenity-8b856bd5a12f0d9edbdea60916900fd3f7f40823.zip |
Toolchain: Fix expansion bugs and make BuildIt.sh shellcheck compliant
BuildIt.sh had a bunch of SC2086 errors, where we were not quoting
variables in variable expansions. The logic being:
Quoting variables prevents word splitting and glob expansion,
and prevents the script from breaking when input contains spaces,
line feeds, glob characters and such.
Reference: https://github.com/koalaman/shellcheck/wiki/SC2086
As bcoles noticed in #6772, shellcheck actually found a real bug here,
where the user's build directory included spaces.
Close: #6772
-rwxr-xr-x | Toolchain/BuildIt.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Toolchain/BuildIt.sh b/Toolchain/BuildIt.sh index 9a665c3359..ff0c861ffd 100755 --- a/Toolchain/BuildIt.sh +++ b/Toolchain/BuildIt.sh @@ -258,8 +258,8 @@ pushd "$DIR/Build/$ARCH" perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure" fi - if [ ! -f $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-userland.h ]; then - cp $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h + if [ ! -f "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-userland.h" ]; then + cp "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h" "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h" fi for STAGE in Userland Kernel; do @@ -277,9 +277,9 @@ pushd "$DIR/Build/$ARCH" REALTARGET="$PREFIX/Kernel" fi - cp $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h + cp "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h" "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h" if [ "$STAGE" = "Userland" ]; then - sed -i='' 's@-fno-exceptions @@' $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h + sed -i='' 's@-fno-exceptions @@' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h" fi buildstep "gcc/configure/${STAGE,,}" "$DIR/Tarballs/gcc-$GCC_VERSION/configure" --prefix="$PREFIX" \ @@ -302,16 +302,16 @@ pushd "$DIR/Build/$ARCH" fi buildstep "libgcc/build" "$MAKE" -j "$MAKEJOBS" all-target-libgcc || exit 1 echo "XXX install gcc and libgcc" - buildstep "gcc+libgcc/install" "$MAKE" DESTDIR=$TEMPTARGET install-gcc install-target-libgcc || exit 1 + buildstep "gcc+libgcc/install" "$MAKE" DESTDIR="$TEMPTARGET" install-gcc install-target-libgcc || exit 1 fi echo "XXX build libstdc++" buildstep "libstdc++/build/${STAGE,,}" "$MAKE" -j "$MAKEJOBS" all-target-libstdc++-v3 || exit 1 echo "XXX install libstdc++" - buildstep "libstdc++/install/${STAGE,,}" "$MAKE" DESTDIR=$TEMPTARGET install-target-libstdc++-v3 || exit 1 + buildstep "libstdc++/install/${STAGE,,}" "$MAKE" DESTDIR="$TEMPTARGET" install-target-libstdc++-v3 || exit 1 mkdir -p "$REALTARGET" - cp -a $TEMPTARGET/$PREFIX/* "$REALTARGET/" + cp -a "$TEMPTARGET"/"$PREFIX"/* "$REALTARGET/" rm -rf "$TEMPTARGET" popd |