Skip to content

Instantly share code, notes, and snippets.

@LilinYume
Last active August 29, 2015 14:05
Show Gist options
  • Save LilinYume/706968c9a238a4293405 to your computer and use it in GitHub Desktop.
Save LilinYume/706968c9a238a4293405 to your computer and use it in GitHub Desktop.
#!/bin/bash
def_name="$PWD/main.c"
file_name=''
flag=0
reply=''
if [ -f $def_name ]; then
gcc $def_name
else
printf "file name? "
read file_name
if [ -f "$PWD/$file_name" ]; then
gcc $file_name
else
echo 'file not found'
flag=1
fi
fi
# gcc return status
if [ $? == 0 ]; then
flag=0
else
flag=1
fi
if [ -f "$PWD/a.out" ]; then
flag=0
else
flag=1
fi
if [ $flag -eq 0 ]; then
printf 'execute a.out? (y/n) '
read reply
case $reply in
y)
./a.out
;;
n)
;;
*)
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment