Squashed 'cde/programs/dtksh/ksh93/' content from commit b16c91f01

git-subtree-dir: cde/programs/dtksh/ksh93
git-subtree-split: b16c91f0120895eaae2618e821cac5b4eda27ac2
This commit is contained in:
Jon Trulson
2022-08-27 13:53:17 -06:00
commit 97ef0077f0
1152 changed files with 330758 additions and 0 deletions

33
bin/Mamfile_indent Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env sh
IFS=''; set -fCu # safe mode: no split/glob = no quoting headaches
let() { return $((!($1))); }
# Automatically (re-)indent make...done blocks in a Mamfile.
# Usage: Mamfile_indent <Mamfile >Mamfile.new
#
# Should work on all current POSIX compliant shells.
# By Martijn Dekker <martijn@inlv.org>, 2021. Public domain.
# Spacing per indentation level. Edit to change style.
indent=' ' # one tab
# Remove existing indentation, add new indentation.
indentlvl=0
sed 's/^[[:space:]]*//' \
| while read -r line
do case $line in
'') continue ;;
done*) let "indentlvl -= 1" ;;
esac
spc=
i=0
while let "(i += 1) <= indentlvl"
do spc=$indent$spc
done
printf '%s\n' $spc$line
case $line in
make*) let "indentlvl += 1" ;;
esac
done