Skip to content

Instantly share code, notes, and snippets.

@ekibun
Created July 1, 2021 09:35
Show Gist options
  • Save ekibun/d48fd25465152712b3ceee8085e086ce to your computer and use it in GitHub Desktop.
Save ekibun/d48fd25465152712b3ceee8085e086ce to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
if [ $1 == "ln" ]; then
tgtdir=$( dirname "$3" )
tgtbase=$( basename "$3" )
windir=$( wslpath -w "$tgtdir" )
cmd.exe /c mklink /J "$windir\\$tgtbase" "$( wslpath -w "$2" )"
else
# https://github.com/microsoft/WSL/issues/6420
tmp=$( mktemp -p /tmp )
mv $tmp $tmp.bat
trap "rm $tmp.bat; exit" SIGHUP SIGINT SIGTERM
echo $1.exe ${*:2} > $tmp.bat
cmd.exe /C $( wslpath -m $tmp.bat )
rm $tmp.bat
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment