From 7abf5c16413daf943d6360e4547fa0ee8f50f3b4 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 14 Apr 2023 15:33:05 -0400 Subject: [PATCH] TABS.sh is now able to check for and remove tabs from files Former-commit-id: 6267fa7949d07a8498cb87d014ababab9df296ce Former-commit-id: dad2b25c3971213a5179af19739ec03bab962212 --- port-jobs/TABS.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/port-jobs/TABS.sh b/port-jobs/TABS.sh index 14a3ca3..1cd337d 100755 --- a/port-jobs/TABS.sh +++ b/port-jobs/TABS.sh @@ -2,10 +2,15 @@ if [ "$1" = 'TABS' ]; then unexpand -t 4 working/sshyp.py > working/sshyp.py.new unexpand -t 4 working/sshync.py > working/sshync.py.new -else - expand -t 4 working/sshyp.py > working/sshyp.py.new - expand -t 4 working/sshync.py > working/sshync.py.new + mv working/sshyp.py.new working/sshyp.py + mv working/sshync.py.new working/sshync.py + chmod +x working/sshyp.py working/sshync.py +elif [ "$(grep -qP '\t' "$1" && echo TABS)" = 'TABS' ]; then + printf "$1 contains tab characters...\n" + read -rp 'replace with (4) spaces? (Y/n) ' replace + if [ "$replace" != 'n' ] && [ "$replace" != 'N' ]; then + expand -t 4 "$1" > "$1".new + chmod --reference="$1" "$1".new + mv "$1".new "$1" + fi fi -mv working/sshyp.py.new working/sshyp.py -mv working/sshync.py.new working/sshync.py -chmod +x working/sshyp.py working/sshync.py