diff options
author | kx <kx@radix.pro> | 2023-04-07 06:34:02 +0300 |
---|---|---|
committer | kx <kx@radix.pro> | 2023-04-07 06:34:02 +0300 |
commit | f84701650cb9f48ae55290e4091d70b334b907d5 (patch) | |
tree | c9279e9123858cbd82a11f8e1a27691d8b554c81 /auto-clean | |
parent | 890f8e901f0ea339efae789a00ac4fc561303e29 (diff) | |
download | jsmin-f84701650cb9f48ae55290e4091d70b334b907d5.tar.xz |
Diffstat (limited to 'auto-clean')
-rwxr-xr-x | auto-clean | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/auto-clean b/auto-clean new file mode 100755 index 0000000..84d1b59 --- /dev/null +++ b/auto-clean @@ -0,0 +1,40 @@ +#!/bin/bash + +CWD=`pwd` + +program=`basename $0` + +usage() { + cat << EOF + +Usage: $program [options] + +Options: + -h,--help Display this message. + +EOF +} + +if [ -f "${CWD}/Makefile" ] ; then + make distclean +fi + +gitignore='.gitignore' + +while read ln; do + line=`echo "${ln}" | sed 's,^[ \t],,' | sed 's,[ \t]$,,'` + if [ "x$line" != "x" -a "${line:0:1}" != "#" ] ; then + if `echo "${line}" | grep -q '\*~$'` ; then + find "`dirname "${line}"`" -type f -iname '*~' -print0 | while IFS= read -r -d '' file ; do + rm -f "$file" + done + elif `echo "${line}" | grep -q '\*'` ; then + find "`dirname "${line}"`" -type f -iname "`basename "${line}"`" -print0 | while IFS= read -r -d '' file ; do + rm -f "$file" + done + else + if [ -d "${line}" ] ; then rm -rf "${line}" ; fi + if [ -f "${line}" ] ; then rm -f "${line}" ; fi + fi + fi +done < ${CWD}/${gitignore} |