Skip to content

Commit

Permalink
Add double-quotes to shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
panzi authored and mstorsjo committed Nov 21, 2024
1 parent e3c35c0 commit 3216e3f
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 50 deletions.
38 changes: 19 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
set -e

if [ $# -lt 1 ]; then
echo $0 {vc.zip sdk.zip target\|target}
echo "$0 {vc.zip sdk.zip target|target}"
exit 0
fi

if [ $# -eq 3 ]; then
VC_ZIP=$(cd $(dirname $1) && pwd)/$(basename $1)
SDK_ZIP=$(cd $(dirname $2) && pwd)/$(basename $2)
VC_ZIP=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
SDK_ZIP=$(cd "$(dirname "$2")" && pwd)/$(basename "$2")
DEST=$3
else
DEST=$1
fi
ORIG=$(cd $(dirname $0) && pwd)
ORIG=$(cd "$(dirname "$0")" && pwd)

mkdir -p $DEST
cd $DEST
mkdir -p "$DEST"
cd "$DEST"
DEST=$(pwd)

ln_s() {
Expand All @@ -41,7 +41,7 @@ ln_s() {
}

if [ -n "$VC_ZIP" ]; then
unzip $VC_ZIP
unzip "$VC_ZIP"
fi
ln_s "Windows Kits" kits
ln_s VC vc
Expand Down Expand Up @@ -71,8 +71,8 @@ cd ..
# Thus process them to reference the other headers with lowercase names.
# Also lowercase these files, as a few of them do have non-lowercase names,
# and the call to fixinclude lowercases those references.
$ORIG/lowercase -symlink include
$ORIG/fixinclude include
"$ORIG"/lowercase -symlink include
"$ORIG"/fixinclude include
cd bin
# vctip.exe is known to cause problems at some times; just remove it.
# See https://bugs.chromium.org/p/chromium/issues/detail?id=735226 and
Expand All @@ -99,7 +99,7 @@ if [ -d kits/10 ]; then
else
mkdir kits
cd kits
unzip $SDK_ZIP
unzip "$SDK_ZIP"
cd 10
fi
ln_s Lib lib
Expand Down Expand Up @@ -129,27 +129,27 @@ for incdir in um shared winrt km; do
SDK_INCDIR="kits/10/include/$SDKVER/$incdir"

if [ -d "$SDK_INCDIR" ]; then
$ORIG/lowercase -map_winsdk -symlink "$SDK_INCDIR"
$ORIG/fixinclude -map_winsdk "$SDK_INCDIR"
"$ORIG"/lowercase -map_winsdk -symlink "$SDK_INCDIR"
"$ORIG"/fixinclude -map_winsdk "$SDK_INCDIR"
fi
done

# The WDF is a part of the Windows Driver Kit.
WDF_INCDIR="kits/10/include/wdf"
if [ -d "$WDF_INCDIR" ]; then
$ORIG/lowercase -map_winsdk -symlink "$WDF_INCDIR"
$ORIG/fixinclude -map_winsdk "$WDF_INCDIR"
"$ORIG"/lowercase -map_winsdk -symlink "$WDF_INCDIR"
"$ORIG"/fixinclude -map_winsdk "$WDF_INCDIR"
fi

for arch in x86 x64 arm arm64; do
SDK_LIBDIR="kits/10/lib/$SDKVER/um/$arch"
DDK_LIBDIR="kits/10/lib/$SDKVER/km/$arch"

if [ -d "$SDK_LIBDIR" ]; then
$ORIG/lowercase -symlink "$SDK_LIBDIR"
"$ORIG"/lowercase -symlink "$SDK_LIBDIR"
fi
if [ -d "$DDK_LIBDIR" ]; then
$ORIG/lowercase -symlink "$DDK_LIBDIR"
"$ORIG"/lowercase -symlink "$DDK_LIBDIR"
fi
done

Expand All @@ -169,7 +169,7 @@ if [ -d "VC/Tools/MSVC/$MSVCVER/modules" ]; then
ln_s VC/Tools/MSVC/$MSVCVER/modules modules
fi

cat $ORIG/wrappers/msvcenv.sh \
cat "$ORIG"/wrappers/msvcenv.sh \
| sed 's/MSVCVER=.*/MSVCVER='$MSVCVER/ \
| sed 's/SDKVER=.*/SDKVER='$SDKVER/ \
| sed s/x64/$host/ \
Expand All @@ -181,14 +181,14 @@ for arch in x86 x64 arm arm64; do
continue
fi
mkdir -p bin/$arch
cp -a $ORIG/wrappers/* bin/$arch
cp -a "$ORIG"/wrappers/* bin/$arch
cat msvcenv.sh | sed 's/ARCH=.*/ARCH='$arch/ > bin/$arch/msvcenv.sh
done
rm msvcenv.sh

if [ -d "$DEST/bin/$host" ]; then
if WINE="$(command -v wine64 || command -v wine)"; then
WINEDEBUG=-all ${WINE} wineboot &>/dev/null
WINEDEBUG=-all "${WINE}" wineboot &>/dev/null
echo "Build msvctricks ..."
"$DEST/bin/$host/cl" /EHsc /O2 "$ORIG/msvctricks.cpp"
if [ $? -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions wrappers/armasm
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/armasm.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/armasm.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/armasm64
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/armasm64.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/armasm64.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/cl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
. "$(dirname "$0")"/msvcenv.sh

# /showIncludes
unixify_path='/^Note: including file: /{ s/z:([\\/])/\1/i; s,\\,/,g; }'
Expand All @@ -26,7 +26,7 @@ unixify_note='/^[zZ]:.*\([[:digit:]]+\): (note|error C[[:digit:]]{4}|warning C[[
export WINE_MSVC_STDOUT_SED="$unixify_path;$unixify_line;$unixify_note"
export WINE_MSVC_STDERR_SED="$unixify_path"

$(dirname $0)/wine-msvc.sh $BINDIR/cl.exe "$@"
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/cl.exe "$@"

ec=$?
[ $ec -ne 0 ] && exit $ec
Expand Down
4 changes: 2 additions & 2 deletions wrappers/dumpbin
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
. "$(dirname "$0")"/msvcenv.sh

# /PDBPATH
unixify_path='/^(Dump of file | PDB file found at )/{ s/z:([\\/])/\1/i; s,\\,/,g; }'

export WINE_MSVC_STDOUT_SED="$unixify_path"

$(dirname $0)/wine-msvc.sh $BINDIR/dumpbin.exe "$@"
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/dumpbin.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/lib
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/lib.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/lib.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/link
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/link.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/link.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/mc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/mc.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/mc.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/midl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/midl.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/midl.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/ml.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/ml.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/ml64
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/ml64.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/ml64.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
. "$(dirname "$0")"/msvcenv.sh

# By default, the platform-specific settings for the current project override
# the PATH, INCLUDE, LIB, LIBPATH, CONFIGURATION, and PLATFORM environment
Expand Down Expand Up @@ -93,4 +93,4 @@ if [[ "${MSBUILDBINDIR}" == *amd64 ]]; then
fi

export WINE_MSVC_RAW_STDOUT=1
$(dirname $0)/wine-msvc.sh ${MSBUILDBINDIR}/MSBuild.exe "$@"
"$(dirname "$0")"/wine-msvc.sh "${MSBUILDBINDIR}"/MSBuild.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/mt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/mt.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/mt.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/nmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/nmake.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/nmake.exe "$@"
4 changes: 2 additions & 2 deletions wrappers/rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/rc.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/rc.exe "$@"
6 changes: 3 additions & 3 deletions wrappers/wine-msvc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ WINE=$(command -v wine64 || command -v wine || false)
export WINEDEBUG=${WINEDEBUG:-"-all"}

if [ -n "$WINE_MSVC_RAW_STDOUT" ]; then
$WINE "$EXE" "${ARGS[@]}"
"$WINE" "$EXE" "${ARGS[@]}"
exit $?
fi

WINE_MSVC_STDOUT_SED='s/\r//;'"$WINE_MSVC_STDOUT_SED"
WINE_MSVC_STDERR_SED='s/\r//;'"$WINE_MSVC_STDERR_SED"

if [ ! -f "$MSVCTRICKS_EXE" ]; then
$WINE "$EXE" "${ARGS[@]}" 2> >(sed -E "$WINE_MSVC_STDERR_SED" >&2) | sed -E "$WINE_MSVC_STDOUT_SED"
"$WINE" "$EXE" "${ARGS[@]}" 2> >(sed -E "$WINE_MSVC_STDERR_SED" >&2) | sed -E "$WINE_MSVC_STDOUT_SED"
exit $PIPESTATUS
else
export WINE_MSVC_STDOUT=${TMPDIR:-/tmp}/wine-msvc.stdout.$$
Expand All @@ -84,7 +84,7 @@ else

cleanup && mkfifo $WINE_MSVC_STDOUT $WINE_MSVC_STDERR || exit 1

$WINE "$MSVCTRICKS_EXE" "$EXE" "${ARGS[@]}" &>/dev/null &
"$WINE" "$MSVCTRICKS_EXE" "$EXE" "${ARGS[@]}" &>/dev/null &
pid=$!
sed -E "$WINE_MSVC_STDOUT_SED" <$WINE_MSVC_STDOUT || kill $pid &>/dev/null &
sed -E "$WINE_MSVC_STDERR_SED" <$WINE_MSVC_STDERR >&2 || kill $pid &>/dev/null &
Expand Down

0 comments on commit 3216e3f

Please sign in to comment.