From 996a7fd061af73f7b8d69fcf91d8f5c0393b9a01 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 22 Mar 2008 12:51:44 +0000 Subject: [PATCH] findlinks, mklinks, mdw-setup: Spruce up style. Also fix a number of quoting bugs, and finally expunge the remaining RCS tags. Remove hints of Debian weirdness from mdw-setup (the actual functionality vanished in 1f79a05...), and make it support AC_CONFIG_AUX_DIR and AC_CONFIG_HEADER properly. --- findlinks.in | 122 +++++++++++++++++++++++++++++++---------------------------- mdw-setup | 66 +++++++++++++++++++++++++------- mklinks.in | 78 +++++++++++++++++++------------------- 3 files changed, 156 insertions(+), 110 deletions(-) diff --git a/findlinks.in b/findlinks.in index 13380be..2790b92 100755 --- a/findlinks.in +++ b/findlinks.in @@ -1,39 +1,39 @@ #! /bin/sh -# -*-sh-*- -# -# Find files which could be links to the repository -# -# (c) 1997 Mark Wooding -# +### -*-sh-*- +### +### Find files which could be links to the repository +### +### (c) 1997 Mark Wooding +### -#----- Licensing notice ----------------------------------------------------- -# -# This file is part of the Common Files Distribution (`common'). -# -# `Common' is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# `Common' is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with `common'; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common'). +### +### `Common' is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### `Common' is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# --- Configuration variables --- +set -e -prefix=@prefix@ -datarootdir=@datarootdir@ -datadir=@datadir@/@PACKAGE@ +pkgdatadir="@pkgdatadir@" +VERSION="@VERSION@" -# --- Parse command line arguments --- +###-------------------------------------------------------------------------- +### Parse command line arguments. while [ $# -gt 0 ]; do - case $1 in + case "$1" in -h | --h | --he | --hel | --help) cat < done -# -# I have to stick the whole lot in backticks and echo the result when it's -# all done. Yuk. -# -# Oh, I almost forgot: that colon on the end there, that's to make sure that -# all the entries are surrounded by colons on both sides, which makes the -# pattern match in the `case' below work properly. +###-------------------------------------------------------------------------- +### Read the names of all the files I support. +### +### +### Yes, this is ugly and hacky: well spotted. Shells have a nasty habit of +### spontaneously forking when redirection gets too hard for them to think +### about, so instead of something nice along the lines of +### +### find ... | while read name; do done +### +### I have to stick the whole lot in backticks and echo the result when it's +### all done. Yuk. +### +### Oh, I almost forgot: that colon on the end there, that's to make sure +### that all the entries are surrounded by colons on both sides, which makes +### the pattern match in the `case' below work properly. -files=` +files=$( files="" - find $datadir -type f -print | { while read name; do - files="$files:\`echo $name | sed -e 's;^.*/;;'\`" - done - echo $files; } `: + find "$pkgdatadir" -type f -print | { + while read name; do + files="$files:$(echo "$name" | sed 's;^.*/;;')" + done + echo $files + } +): -# --- Now examine the current directory --- -# -# Remember to include things which are already linked, so that users can say -# `findlinks >.links' without any problems. +###-------------------------------------------------------------------------- +### Now examine the current directory. +### +### Remember to include things which are already linked, so that users can +### say `findlinks >.links' without any problems. find . \( -type f -o -type l \) -print | while read name; do - base="`echo $name | sed -e 's;^.*/;;'`" + base="$(echo "$name" | sed 's;^.*/;;')" case "$files" in *:$base:*) echo $name ;; *) esac -done | sed -e 's,^\./,,' | sort +done | sed 's,^\./,,' | sort + +###----- That's all, folks -------------------------------------------------- diff --git a/mdw-setup b/mdw-setup index f3ffe95..57dbd90 100755 --- a/mdw-setup +++ b/mdw-setup @@ -1,22 +1,46 @@ #! /bin/sh +### -*-sh-*- +### +### Create links to the repository +### +### (c) 1997 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common'). +### +### `Common' is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### `Common' is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. set -e -### Basic setup stuff +###-------------------------------------------------------------------------- +### Basic setup stuff. + ego=$(echo "$0" | sed 's:^.*[/\\]::; s:\.*$::') -usage="Usage: $ego [--debian]" +usage="Usage: $ego" + +###-------------------------------------------------------------------------- +### Parse command line arguments. -### Parse options -debian=no while [ $# -gt 0 ]; do case "$1" in --help | -h | --usage | -u) echo "$usage" exit ;; - --debian) - debian=yes - ;; --) shift break @@ -28,18 +52,25 @@ while [ $# -gt 0 ]; do esac shift done + if [ $# -ne 0 ]; then echo >&2 "$usage" exit 1 fi -### Link any strange common files we need +###-------------------------------------------------------------------------- +### Link any strange common files we need. + [ -f .links ] && mklinks -### Do any local stuff +###-------------------------------------------------------------------------- +### Do any initial local stuff. + [ -x build-setup ] && ./build-setup start -### Grind through the Autoconf machinery +###-------------------------------------------------------------------------- +### Grind through the Autoconf machinery. + configure= for i in configure.ac configure.in; do [ -f $i ] && configure=$i @@ -55,10 +86,19 @@ if [ "$configure" ]; then aclocalargs= for i in config m4; do [ -d $i ] && aclocalargs="$aclocalargs -I $i"; done aclocal $aclocalargs - autoconf - grep >/dev/null AM_CONFIG_HEADER $configure && autoheader + autoconf --force + if grep >/dev/null 'AC_CONFIG_AUX_DIR' $configure; then + auxdir=$( + sed -n 's:^.*AC_CONFIG_AUX_DIR(\[\?\([^])]*\)\]\?).*$:\1:p' $configure) + mkdir -p $auxdir + fi + grep >/dev/null 'A[MC]_CONFIG_HEADER' $configure && autoheader [ -f Makefile.am ] && automake -a fi -### Do any local stuff +###-------------------------------------------------------------------------- +### Do any final local stuff. + [ -x build-setup ] && ./build-setup end + +###------ That's all, folks ------------------------------------------------- diff --git a/mklinks.in b/mklinks.in index af3ac2c..0d57afd 100755 --- a/mklinks.in +++ b/mklinks.in @@ -1,40 +1,39 @@ #! /bin/sh +### -*-sh-*- +### +### Create links to the repository +### +### (c) 1997 Mark Wooding +### -# -*-sh-*- -# -# Create links to the repository -# -# (c) 1997 Mark Wooding -# +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common'). +### +### `Common' is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### `Common' is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#----- Licensing notice ----------------------------------------------------- -# -# This file is part of the Common Files Distribution (`common'). -# -# `Common' is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# `Common' is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with `common'; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +set -e -# --- Configuration variables --- +pkgdatadir="@pkgdatadir@" +VERSION="@VERSION@" -prefix=@prefix@ -datarootdir=@datarootdir@ -datadir=@datadir@/@PACKAGE@ - -# --- Parse command line arguments --- +###-------------------------------------------------------------------------- +### Parse command line arguments. while [ $# -gt 0 ]; do - case $1 in + case "$1" in -h | --h | --he | --hel | --help) cat <