Sponsors
Submitted by xman on Mon, 23/04/2007 - 11:26am
Posted in
Previous script xman_dos2unix in xman utility (latest) under GPL has problems on files or directories with space.
Simple work around with double quotes:
for file in "$@" ; do ... done
Note that all references to $file requires double quotes too.
Another tedious work around with IFS and double quotes:
I use IFS=$'\n', and double quote references to files such as "${file}" to solve the space problems.
OLDIFS=$IFS
IFS=$'\n'
for file in $@ ; do
# FIXME: I should have put these into a subroutine to reduce code duplications in explore().
# However, I'm not familiar with subroutines in BASH yet.
# echo "$file"
IFS=$OLDIFS
if [ -d "$file" ] ; then
echo "Entering $file"
pushd "$file" > /dev/null
explore
echo "Leaving $file"
popd
elif [ "`${FILE} \"${file}\" | ${GREP} text`" != "" ] ; then
$DOS2UNIX "$file"
fi
IFS=$'\n'
done
IFS=$OLDIFS

I have seen xarg used in
Post new comment