MEDLEY-UILS loadup-db run-medley fixes (#808)
* MEDLEY-UILS loadup-db run-medley fixes * UNIXCOMM compile to DFASL; only set UTF-8 if getenv(LANG). loadup-db no lisp.virtualmem
This commit is contained in:
61
scripts/cpv
Executable file
61
scripts/cpv
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
# cpv file dest
|
||||
# could extend with -r or copying multiple files
|
||||
# could change from cp to ln
|
||||
|
||||
file="$1"
|
||||
dest="$2"
|
||||
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo no such file "$file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if dest is a directory, add the source file name
|
||||
if [ -d "$dest" ]; then
|
||||
dest=$dest/`basename $file`
|
||||
fi
|
||||
|
||||
# if no such file $dest then just copy
|
||||
if [ ! -f "$dest" ]; then
|
||||
ln $file $dest #WAS cp -p $file $dest
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# find maximum version of dest
|
||||
max=0
|
||||
for vf in "$dest".~[1-9]*~
|
||||
do vn=`echo $vf | sed -e 's/^.*\.~\([1-9][0-9]*\)~$/\1/'`
|
||||
if [ -f $dest.~$vn~ ]; then
|
||||
if [ $max -lt $vn ]; then
|
||||
max=$vn
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $max -eq 0 ]; then # no current versions
|
||||
mv $dest $dest.~1~ # change version to version 1
|
||||
new=2
|
||||
else
|
||||
if cmp -q $dest $dest.~$max~ >/dev/null 2>&1
|
||||
then # they're different
|
||||
max=`expr $max + 1` # make newer version
|
||||
mv $dest $dest.~$max~
|
||||
new=`expr $max + 1`
|
||||
else # dest and dest.~nn~ are equal so
|
||||
rm $dest # delete dest leave old version behind
|
||||
new=`expr $max + 1`
|
||||
fi
|
||||
fi
|
||||
|
||||
# make new version
|
||||
|
||||
ln $file $dest.~$new~ # cp -p $file $dest.~$new~
|
||||
ln $dest.~$new~ $dest # and link it
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user