All pastes #226678 Raw Edit

##linux words

public text v1 · immutable
#226678 ·published 2006-10-28 19:05 UTC
rendered paste body
!/bin/bash
## compilecpp by highneko :3
## compile .cpp file and execute compiled binary file
## change g++ compile parameters to your liking

a="$1" 
b="${1%.*}" 
c=`ls -l --time-style=full-iso | grep "$b" | sed 1q` 

 ## if filename was given and exists
if [ -f "$a" ]; then

g++ "$a" -Wno-deprecated -lglut -lGLU -lGL -o "$b" ## compile file
elif [ -n "$a" ]; then ## else if unknown parameter
echo "error: can't find file: $a" ## if file not found echo error message
else ## else
echo "error: no input file found" ## if no filename was given echo error message
fi ## end if
d=`ls -l --time-style=full-iso | grep "$b" | sed 1q` ## variables
if [ "$c" = "$d" ]; then #file has not changed
echo "compile error" #echo error message
else ## else
echo "compile successful" #echo success
chmod 755 "$b" ## make file executable for ugo
./"$b" ## execute c++ binary file
fi ## end if