Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #!/bin/bash
  2. fullpath=$1
  3. filename="${fullpath##*/}" # Strip longest match of */ from start
  4. dir="${fullpath:0:${#fullpath} - ${#filename}}" # Substring from 0 thru pos of filename
  5. base="${filename%.[^.]*}" # Strip shortest match of . plus at least one non-dot char from end
  6. ext="${filename:${#base} + 1}" # Substring from len of base thru end
  7. if [[ -z "$base" && -n "$ext" ]]; then # If we have an extension and no base, it's really the base
  8. base=".$ext"
  9. ext=""
  10. fi
  11. localFlag="-DLOCAL"
  12. if [ "$ext" == "f" ]; then
  13. ext=
  14. localFlag=
  15. fi
  16. exe="${base}.e"
  17. if [ "$ext" == "" ]; then
  18. if [ -e "${base}.cpp" ]; then
  19. script="${base}.cpp"
  20. else if [ -e "${base}.c" ]; then
  21. script="${base}.c"
  22. fi
  23. fi
  24. else
  25. script="${base}.${ext}"
  26. fi;
  27. code=0
  28. o=
  29. if [ "$script" -nt "$exe" ]; then
  30. 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`
  31. code=$?
  32. fi
  33. if [ $code -eq 0 ]; then
  34. echo "Zbudowano!" >&2
  35. echo "$o" >&2
  36. if [[ "$2" != "" ]]; then
  37. if [ "$o" != "" ]; then
  38. sleep 2;
  39. fi
  40. if [[ -f $2 ]]; then
  41. echo " Input from file: ${@:2}">&2
  42. ./$exe < ${@:2}
  43. else
  44. echo " Input from args.">&2
  45. ./$exe <<< "${@:2}"
  46. fi
  47. else echo>&2; fi
  48. else
  49. echo "$o" | less
  50. exit $code
  51. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement