-
-
Save kmplngj/bf014ed054fce7b012ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SWIFT=$(/usr/bin/env xcrun -f swift) | |
SCRIPTPATH=$1 | |
COMPILEDPATH="$SCRIPTPATH.o" | |
SDKPATH=$(/usr/bin/env xcrun --show-sdk-path --sdk macosx) | |
#compile if necessary | |
if [ $SCRIPTPATH -nt $COMPILEDPATH ]; then | |
$SWIFT -o "$COMPILEDPATH" -sdk "$SDKPATH" "$SCRIPTPATH" | |
if [ $? -ne 0 ]; then | |
exit $? | |
fi | |
fi | |
# ${@:n} passes on all arguments, sarting with the nth, "${@:n}" makes it work iwth escaped arguments as well (spaces, etc) | |
$COMPILEDPATH "${@:2}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment