Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- fullpath=$1
- filename="${fullpath##*/}" # Strip longest match of */ from start
- dir="${fullpath:0:${#fullpath} - ${#filename}}" # Substring from 0 thru pos of filename
- base="${filename%.[^.]*}" # Strip shortest match of . plus at least one non-dot char from end
- ext="${filename:${#base} + 1}" # Substring from len of base thru end
- if [[ -z "$base" && -n "$ext" ]]; then # If we have an extension and no base, it's really the base
- base=".$ext"
- ext=""
- fi
- localFlag="-DLOCAL"
- if [ "$ext" == "f" ]; then
- ext=
- localFlag=
- fi
- exe="${base}.e"
- if [ "$ext" == "" ]; then
- if [ -e "${base}.cpp" ]; then
- script="${base}.cpp"
- else if [ -e "${base}.c" ]; then
- script="${base}.c"
- fi
- fi
- else
- script="${base}.${ext}"
- fi;
- code=0
- o=
- if [ "$script" -nt "$exe" ]; then
- o=`g++ -I/home/zygzagz/ownCloud/Informatyka/biblioteczka/ -fdiagnostics-color=always -g $localFlag -Wpedantic -Wall -Wunused-variable -Wmaybe-uninitialized -Wno-unused-result -Wshadow -Wextra -Wreturn-local-addr -O3 -std=gnu++1z -D_GLIBCXX_DEBUG -o "$exe" "$script" 2>&1`
- code=$?
- fi
- if [ $code -eq 0 ]; then
- echo "Zbudowano!" >&2
- echo "$o" >&2
- if [[ "$2" != "" ]]; then
- if [ "$o" != "" ]; then
- sleep 2;
- fi
- if [[ -f $2 ]]; then
- echo " Input from file: ${@:2}">&2
- ./$exe < ${@:2}
- else
- echo " Input from args.">&2
- ./$exe <<< "${@:2}"
- fi
- else echo>&2; fi
- else
- echo "$o" | less
- exit $code
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement