Last active
August 29, 2015 14:05
-
-
Save LilinYume/706968c9a238a4293405 to your computer and use it in GitHub Desktop.
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
#!/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