X-Git-Url: https://git.distorted.org.uk/~mdw/cfd/blobdiff_plain/4969747bc3a6b88c53247ea88776799109c081be..282625e1b87743236f1cb8c70c2762edd413c6b0:/findlinks.in diff --git a/findlinks.in b/findlinks.in index 60373f0..fbbcd98 100755 --- a/findlinks.in +++ b/findlinks.in @@ -1,50 +1,39 @@ #! /bin/sh -# -*-sh-*- -# -# $Id: findlinks.in,v 1.2 1999/11/11 17:49:15 mdw Exp $ -# -# 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. -#----- Revision history ----------------------------------------------------- -# -# $Log: findlinks.in,v $ -# Revision 1.2 1999/11/11 17:49:15 mdw -# Regular expression fixes for parsing version numbers. -# -# Revision 1.1.1.1 1999/05/05 19:23:47 mdw -# New import. The old CVS repository was lost in a disk disaster. -# +set -e -# --- Configuration variables --- +pkgdatadir="@pkgdatadir@" +VERSION="@VERSION@" -prefix=@prefix@ -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 < 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="" - find $datadir -type f -print | { while read name; do - files="$files:\`echo $name | sed -e 's;^.*/;;'\`" - done - echo $files; } `: +files=$( + files=: + find "$pkgdatadir" -type f -print | { + while read name; do + files="$files${name##*/}:" + 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=${name##*/} case "$files" in - *:$base:*) - echo $name + *:"$base":*) + echo "${name#./}" ;; *) esac -done | sed -e 's,^\./,,' | sort +done | sort + +###----- That's all, folks --------------------------------------------------