Last active
August 29, 2015 13:57
-
-
Save iyedb/9358027 to your computer and use it in GitHub Desktop.
A small bash script to compile and execute one file C++ programs
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 | |
#./ce.sh filename.cxx|cpp args... | |
CC="c++ -std=c++11 -o" | |
src_name=$1 | |
exe_name=${src_name%.c[px]*} | |
if [ -f "$exe_name" ] | |
then | |
echo "delete $exe_name" | |
rm "$exe_name" | |
fi | |
compile_line="$CC $exe_name $1" | |
echo "compiling: $compile_line" | |
$compile_line | |
if [ $? -eq 0 ] | |
then | |
echo "compiling OK" | |
shift | |
echo "$exe_name output:" | |
echo | |
./$exe_name $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./ce.sh filename.cxx|cpp args...
(ce = compile execute)