Much cleaner compiler script (#692)

Co-authored-by: Salman Abedin <salmanabedin@zohomail.com>
This commit is contained in:
Salman Abedin 2020-06-07 05:17:35 +06:00 committed by GitHub
parent 7572627e85
commit a275422d47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@
file=$(readlink -f "$1") file=$(readlink -f "$1")
dir=${file%/*} dir=${file%/*}
base="${file%.*}" base="${file%.*}"
ext="${file##*.}"
cd "$dir" || exit cd "$dir" || exit
@ -25,25 +26,25 @@ textype() { \
$command --output-directory="$dir" "$base" $command --output-directory="$dir" "$base"
} }
case "$file" in case "$ext" in
*\.ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;; ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
*\.mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;; mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
*\.[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;; [0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
*\.[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;; [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
*\.tex) textype "$file" ;; tex) textype "$file" ;;
*\.md) if command -v lowdown >/dev/null; then md) if command -v lowdown >/dev/null; then
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
elif command -v groffdown >/dev/null; then elif command -v groffdown >/dev/null; then
groffdown -i "$file" | groff > "$base.pdf" groffdown -i "$file" | groff > "$base.pdf"
else else
pandoc "$file" --pdf-engine=xelatex -o "$base".pdf pandoc "$file" --pdf-engine=xelatex -o "$base".pdf
fi ; ;; fi ; ;;
*config.h) sudo make install ;; h) sudo make install ;;
*\.c) cc "$file" -o "$base" && "$base" ;; c) cc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;; py) python "$file" ;;
*\.m) octave "$file" ;; m) octave "$file" ;;
*\.scad) openscad -o "$base".stl "$file" ;; scad) openscad -o "$base".stl "$file" ;;
*\.go) go run "$file" ;; go) go run "$file" ;;
*\.sent) setsid -f sent "$file" 2>/dev/null ;; sent) setsid -f sent "$file" 2>/dev/null ;;
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac esac