+++ /dev/null
-#! /bin/sh
-
-set -e
-if [ $# -ne 3 ]; then
- echo >&2 "usage: $0 install|rm GLOB DIR"
- exit 1
-fi
-
-mode=$1 glob=$2 dir=$3
-case $mode in
- rm)
- printf "Uninstalling aclocal fragments... "
- awk -v dir="$dir" '
- /\*@-([a-zA-Z0-9][-a-zA-Z0-9_]*)-@\*/ {
- out = $0;
- sub(/^.*\*@-/, "", out);
- sub(/-@\*.*$/, "", out);
- system(sprintf("rm %s/%s.m4", dir, out));
- }' <"$glob"
- echo "done."
- ;;
- install)
- printf "Installing aclocal fragments... "
- awk -v dir="$dir" '
- BEGIN { out = ""; delete files; notice = ""}
- /\*@--NOTICE--@\*/ {
- if (out != "") close(out);
- out = "NOTICE";
- notice = $0 "\n";
- next;
- }
- /\*@-([a-zA-Z0-9][-a-zA-Z0-9_]*)-@\*/ {
- if (out != "") close(out);
- out = $0;
- sub(/^.*\*@-/, "", out);
- sub(/-@\*.*$/, "", out);
- files[out] = 1;
- out = sprintf("%s/%s.new", dir, out);
- printf "%s", notice >(out);
- }
- /\*@--[-a-zA-Z0-9_]*-@\*/ { next; }
- {
- if (out == "NOTICE")
- notice = notice $0 "\n";
- else
- if (out != "") print $0 >(out);
- }
- END {
- for (f in files)
- system(sprintf("mv %s/%s.new %s/%s.m4", dir, f, dir, f));
- }' <"$glob"
- echo "done."
- ;;
- *) echo >&2 "bad mode argument"; exit 1;;
-esac
-
-awk
\ No newline at end of file