Created
October 15, 2021 19:06
-
-
Save 0xkarambit/fc9552f1daa249e54babe810857ecce9 to your computer and use it in GitHub Desktop.
runc
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
# mv ./run.sh /usr/bin/run | |
# https://stackoverflow.com/questions/18568706/check-number-of-arguments-passed-to-a-bash-script | |
if [ "$#" -ne 1 ]; then | |
echo "Illegal number of parameters" >&2; | |
exit 2; | |
fi | |
function getBaseName () { | |
echo -e "$1" | cut -d "." -f 1; | |
} | |
function compileAndRun () { | |
local name=$(getBaseName "$1"); | |
gcc -Wall -o "$name.out" "$1"; | |
./"$name.out"; | |
} | |
compileAndRun $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment