diff options
Diffstat (limited to 'set-serial.sh')
-rwxr-xr-x | set-serial.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/set-serial.sh b/set-serial.sh new file mode 100755 index 0000000..fe9b442 --- /dev/null +++ b/set-serial.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +set -eu + +set-serial-number() +{ + sed >"$1.tmp" -e '/^$/q' "$1" + echo >>"$1.tmp" "#serial $2" + echo >>"$1.tmp" "" + sed >>"$1.tmp" -e '1,/^$/d' -e '/^#serial .*/,+1d' "$1" + mv "$1.tmp" "$1" +} + +for n in "$@"; do + echo "$n ... " + # Determine the number of revisions that have occurred to the macro. + revision=$(git log -- "$n" | egrep -c '^commit [0-9a-f]') + # Update the serial number in the m4 file. + set-serial-number "$n" "$revision" + # Check whether git regards the file as "modified" now. If it does, + # the serial nmuber needs to be bumped one more time. + if git >/dev/null status -- "$n"; then + set-serial-number "$n" "$((revision + 1))" + fi +done |