57 lines
1.4 KiB
Diff
57 lines
1.4 KiB
Diff
commit fe967bddbd74af9aba435900878397c0c7ea0b0b
|
|
Author: Ruediger Oertel <ro@suse.de>
|
|
Date: Mon Feb 24 11:00:39 2020 +0100
|
|
|
|
added "-h"/"--help" to "old" command (from Bernhard Lang)
|
|
|
|
diff --git a/files/usr/bin/old b/files/usr/bin/old
|
|
index ef2e2b7..5c55aa4 100755
|
|
--- a/files/usr/bin/old
|
|
+++ b/files/usr/bin/old
|
|
@@ -5,22 +5,33 @@
|
|
#
|
|
# Copyright (c) 1996-2002 SuSE Linux AG, Nuernberg, Germany.
|
|
#
|
|
-# please send bugfixes or comments to http://www.suse.de/feedback.
|
|
+# Contributor Bernard Lang
|
|
#
|
|
+# please send bugfixes or comments to
|
|
+# https://github.com/openSUSE/aaa_base/issues
|
|
#
|
|
# usage - tell user to use program
|
|
#
|
|
+# Trick : put a nonexistant file name as first argument if you are worried
|
|
+# about the possibility of files called -h or --help
|
|
+#
|
|
|
|
usage() {
|
|
echo usage: "$0" file\|dir [file\|dir ...]
|
|
}
|
|
|
|
-
|
|
if [ $# -eq 0 ] ; then
|
|
usage
|
|
exit
|
|
fi
|
|
|
|
+if [ "$1" = "-h" -o "$1" = "--help" ] ; then
|
|
+ echo 'Renames file or directory <name> given in argument list to <name>-<date>[<num>]'
|
|
+ echo 'adding when necessary a suffix number <num> to avoid already used names.'
|
|
+ usage
|
|
+ exit
|
|
+fi
|
|
+
|
|
DATESTRING=`date +"%Y%m%d"`
|
|
|
|
for i in "$@" ; do
|
|
@@ -33,6 +44,10 @@ for i in "$@" ; do
|
|
let NUMBER=$NUMBER+1
|
|
done
|
|
echo moving "$i" to "$NEWNAME"
|
|
+ if [ "${i:0:1}" = "-" ] ; then
|
|
+ i="./$i"
|
|
+ NEWNAME="./$NEWNAME"
|
|
+ fi
|
|
mv "$i" "$NEWNAME"
|
|
else
|
|
echo "$i" does not exist.
|