Skip to content

Instantly share code, notes, and snippets.

@HarshitJoshi9152
Created October 15, 2021 19:06
Show Gist options
  • Save HarshitJoshi9152/fc9552f1daa249e54babe810857ecce9 to your computer and use it in GitHub Desktop.
Save HarshitJoshi9152/fc9552f1daa249e54babe810857ecce9 to your computer and use it in GitHub Desktop.
runc
# 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