Created
February 3, 2021 13:25
-
-
Save baerla/edf9b1ed4f0f9a4cdfd9b4d91e7c80c4 to your computer and use it in GitHub Desktop.
Skript to run .cpp and .h C++ files
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 | |
# syntax: ./test.sh <file.h> <arguments> | |
createdNewFile=false | |
file=${1##*/} | |
echo $file | |
filename=${file%.h} | |
echo $filename | |
path=${1%$file} | |
if [[ $file != $filename ]]; then | |
newPath="$path$filename.cpp" | |
echo "Path: $newPath" | |
cat $1 > $newPath | |
createdNewFile=true | |
else #.cpp | |
newPath="$path$file" | |
fi | |
g++ -Wall -std=c++11 ${*:2} $newPath | |
echo -e "\n\n" | |
./a.out #${*:2} | |
rm ./a.out | |
if [[ $createdNewFile == true ]]; then | |
rm $newPath | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment