From 1e5d77c8a4c4daea4a43239dd0be2b06f8c14b64 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Tue, 28 Dec 2021 23:59:05 -0600 Subject: [PATCH] made POSIX compliant --- latex-cleanup | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/latex-cleanup b/latex-cleanup index 3c7a912..6d7044b 100644 --- a/latex-cleanup +++ b/latex-cleanup @@ -3,13 +3,16 @@ #!/bin/sh for f in *.tex; do - h=$(basename "$f" .tex) - echo "Trashing files accompanying $h.tex..." - for g in "$h".*; do - if [[ ${g: -4} != ".tex" && ${g: -4} != ".pdf" ]] ; then - echo "Trashing $g..." - totrash "$g" - fi - done + if [ -f "$f" ]; then + h=$(basename "$f" .tex) + echo "Trashing files accompanying $h.tex..." + for g in "$h".*; do + k=$( echo $g | sed 's/^.*\.//') + if [ "$k" != "tex" ] && [ "$k" != "pdf" ] && [ "$k" != "bib" ] ; then + echo "Trashing $g..." + totrash "$g" + fi + done + fi done echo "Done!"