Created
October 17, 2023 10:46
-
-
Save taikedz/5ba65a45b6eeab954fdcedd8f93bc41f to your computer and use it in GitHub Desktop.
rustr - run rust source file as an executable script
This file contains 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
#!/usr/bin/env bash | |
# Use this `rustr` script as a shebang target. | |
# put `rustr` somewhere on your PATH | |
filename="$1"; shift | |
temp="$(mktemp)" | |
rmtemp() { rm "$temp"; } | |
touch "$temp" | |
trap rmtemp exit | |
if rustc "$filename" -o "$temp"; then | |
chmod 700 "$temp" | |
"$temp" "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment