Kleines Bash-Script, welches ich grade zusammengeflickt habe. Müsste noch erweitert werden.
Vielleicht kanns ja jemand gebrauchen
PHP-Code:
#!/bin/sh
#compile.sh: compile/run all files with one command !
#kingfinn
if [ -e $1 ]; then
#magical regex
file=$(echo "$1" | sed "s/.*\/\(.*\)/\1/")
#special files
case $file in
"Makefile") make -f $1
exit;;
esac
#again some regex magic
path=$(echo "$1" | sed "s/\(.*\)\/.*/\1/")
suffix=$(echo "$file" | sed "s/.*\.\(.*\)/\1/")
#files has no suffix, maybe executable
if [ $suffix == "" ]; then
if [ -x $1 ]; then
cd $path
./$file
exit
fi
fi
#regex <3
filename=$(echo "$file" | sed "s/\(.*\)\..*/\1/")
#now here it goes
if [ $2 == "n" ]; then
case $suffix in
"sh") bash $1;;
"c") gcc -std=c99 -Wall -o $path/$filename $1;;
"py") python3 $1;;
*) "File not (yet) supported!"
esac
else
case $suffix in
"sh") sh $1;;
"c") gcc -Wall -o $path/$filename $1;;
"cpp") g++ -Wall -o $path/$filename $1;;
"py") python $1;;
"pl") perl $1;;
*) echo "File not (yet) supported!"
esac
else
echo "File does not exist!"
fi
MfG