Commit 30db1303 authored by Klaatu's avatar Klaatu
Browse files

added verbosity option and silence by default, plus a help option

parent a22b85b2
......@@ -18,6 +18,29 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# process verbose and help options
while [ True ]; do
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo " "
echo "trash [--verbose] foo"
echo " "
exit
elif [ "$1" = "--verbose" -o "$1" = "-v" ]; then
VERBOSE="-v"
shift 1
else
break
fi
done
# TODO
# if source begins with /run or /media or /mnt ;then
# warn the person that trashing it is copying it from
# that external media onto local drive and do they really
# want to do that?
# either that or we have to make .trash on that device.
# not sure if that is appropriate either.
# sanitize input filenames
ARG=${@// /_}
set -e
......@@ -34,18 +57,16 @@ esac
test -d $BASKET || mkdir -m 700 -p $BASKET 2> /dev/null
# pitch it
if [ "X$ARG" != "X" ]
then
for waste in ${RUBBISH[*]} ; do mv -b "$( echo "${waste}" | sed 's%_%\ %g' )" $BASKET ; done
if [ "X$ARG" != "X" ]; then
for waste in ${RUBBISH[*]} ; do mv $VERBOSE "$( echo "${waste}" | sed 's%_%\ %g' )" $BASKET-$(date +%N) ; done
fi
# tell the user what just happened
if [ "X$2" != "X" ]; then
for i in ${RUBBISH[*]} ; do echo $i "has been moved to the trash." ; done
else
for i in ${RUBBISH[*]} ; do echo $i "has been moved to the trash." ; done
fi
if [ "X$VERBOSE" == "X-v" ]; then
echo "Your Trash is currently $(du -h $BASKET | cut -f1 | tail -n -1) in size."
elif [ "X$ARGS" == "X" ]; then
echo "Your Trash is currently $(du -h $BASKET | cut -f1 | tail -n -1) in size."
else
echo "Your trash is currently $(du -h $BASKET | cut -f1) in size."
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment