"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scripts/notabs.in" between
littleutils-1.2.3.tar.lz and littleutils-1.2.4.tar.lz

About: littleutils are a collection of small and simple utilities (rename files, search for duplicate files, ...).

notabs.in  (littleutils-1.2.3.tar.lz):notabs.in  (littleutils-1.2.4.tar.lz)
#! PROGDASH #! PROGBASH
# vim: set filetype=sh: # vim: set filetype=bash:
# notabs: Converts all tabs in text files to spaces # notabs: Converts all tabs in text files to spaces
# Copyright (C) 2004-2013 by Brian Lindholm. This file is part of the # Copyright (C) 2004-2021 by Brian Lindholm. This file is part of the
# littleutils utility set. # littleutils utility set.
# #
# The notabs utility is free software; you can redistribute it and/or modify it # The notabs utility is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free # under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later version. # Software Foundation; either version 3, or (at your option) any later version.
# #
# The notabs utility is distributed in the hope that it will be useful, but # The notabs utility is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# the littleutils. If not, see <https://www.gnu.org/licenses/>. # the littleutils. If not, see <https://www.gnu.org/licenses/>.
# get a valid temporary directory and set up traps
TMPWILD=`tempname -w notabs_$$` || exit 99
trap 'rm -f ${TMPWILD} ; exit 1' 1 2 3 13 15
trap 'rm -f ${TMPWILD} ; exit 0' 0
# get command-line options # get command-line options
VERBOSITY=1 declare -i VERBOSITY=1
while getopts hqv opts while getopts hqv opts
do do
case $opts in case $opts in
h) echo 'notabs LU_VERSION' h) echo 'notabs LU_VERSION'
echo 'usage: notabs [-h(elp)] filename ...' echo 'usage: notabs [-h(elp)] filename ...'
exit 0 ;; exit 0 ;;
q) VERBOSITY=$((${VERBOSITY}-1)) ;; q) VERBOSITY=$((${VERBOSITY}-1)) ;;
v) VERBOSITY=$((${VERBOSITY}+1)) ;; v) VERBOSITY=$((${VERBOSITY}+1)) ;;
*) echo 'notabs LU_VERSION' *) echo 'notabs LU_VERSION'
echo 'usage: notabs [-h(elp)] filename ...' echo 'usage: notabs [-h(elp)] filename ...'
exit 1 ;; exit 1 ;;
esac esac
done done
shift `expr ${OPTIND} - 1` shift $((${OPTIND}-1))
# set up traps
trap 'rm -f $TMPFILE ; exit 1' 1 2 3 13 15
# run through the files # run through the files
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
# make sure we can read and modify file # make sure we can read and modify file
if [ ! -f "$1" -o ! -r "$1" -o ! -w "$1" ]; then if [ ! -f "$1" -o ! -r "$1" -o ! -w "$1" ]; then
echo "notabs warning: $1 is not a writeable non-directory file" echo "notabs warning: $1 is not a writeable non-directory file"
shift; continue shift; continue
fi fi
# run through expand and sed # run through expand and sed
TMPFILE=`tempname notabs_$$` || exit 99 TMPFILE=$(tempname notabs_$$) || exit 99
expand "$1" | sed -e 's/ *$//' > ${TMPFILE} expand "$1" | sed -e 's/ *$//' > $TMPFILE
# replace if changes occurred # replace if changes occurred
cmp -s "$1" ${TMPFILE} cmp -s "$1" $TMPFILE
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
cp ${TMPFILE} "$1" cp $TMPFILE "$1"
if [ "$VERBOSITY" -gt 0 ]; then if [ $VERBOSITY -gt 0 ]; then
echo "$1: tabs removed" echo "$1: tabs removed"
fi fi
elif [ "$VERBOSITY" -gt 1 ]; then elif [ $VERBOSITY -gt 1 ]; then
echo "$1: unchanged" echo "$1: unchanged"
fi fi
# clean up afterwards # clean up afterwards
rm -f ${TMPFILE} rm -f $TMPFILE
shift shift
done done
rm -f ${TMPWILD}
 End of changes. 11 change blocks. 
17 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)