mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
Added a simple script to do intelligent updating of the
mercury_update_interface.sh: Added a simple script to do intelligent updating of the interface files.
This commit is contained in:
44
scripts/mercury_update_interface.sh
Normal file
44
scripts/mercury_update_interface.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
#
|
||||
# usage:
|
||||
# mercury_update_interface [-v] filename
|
||||
#
|
||||
# Moves `filename.tmp' to `filename', but only if necessary:
|
||||
# if they are identical, then `filename.tmp' is simply removed,
|
||||
# and the time-stamp is left unaltered.
|
||||
#
|
||||
# If the `-v' (verbose) option is specified, then appropriate progress messages
|
||||
# will be printed.
|
||||
#
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
|
||||
verbose=true
|
||||
|
||||
if [ $# -ge 1 ] && [ "$1" = "-v" ]; then
|
||||
verbose=true
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: `basename $0` filename" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
|
||||
if [ ! -f "$filename" ]
|
||||
then
|
||||
$verbose && echo "creating \`$filename'." 1>&2
|
||||
mv -f "$filename.tmp" "$filename"
|
||||
elif cmp -s "$filename.tmp" "$filename"
|
||||
then
|
||||
$verbose && echo "\`$filename' has not changed." 1>&2
|
||||
rm -f "$filename.tmp"
|
||||
else
|
||||
$verbose && echo "\`$filename' has changed." 1>&2
|
||||
mv -f "$filename.tmp" "$filename"
|
||||
fi
|
||||
Reference in New Issue
Block a user