patch-scripts.bash - relocate interpreter paths of Isabelle scripts.
authorwenzelm
Mon Dec 09 16:47:11 1996 +0100 (1996-12-09)
changeset 2350da4f8b250e1a
parent 2349 e9475a7be4ad
child 2351 873ffd6f70c3
patch-scripts.bash - relocate interpreter paths of Isabelle scripts.
patch-scripts.bash
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patch-scripts.bash	Mon Dec 09 16:47:11 1996 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +#
     1.5 +# $Id$
     1.6 +#
     1.7 +# patch-scripts.bash - relocate interpreter paths of Isabelle scripts.
     1.8 +#
     1.9 +
    1.10 +## find binaries
    1.11 +
    1.12 +function findbin()
    1.13 +{
    1.14 +  local DEFAULT="$1"
    1.15 +  local BASE=""
    1.16 +  local BINARY=""
    1.17 +
    1.18 +  if [ -f "$DEFAULT" ]; then	# preferred location
    1.19 +    echo "found $DEFAULT" >&2
    1.20 +    echo "$DEFAULT"
    1.21 +    return
    1.22 +  else				# find in PATH
    1.23 +    BASE=$(basename "$DEFAULT")
    1.24 +    BINARY=$(type -path "$BASE")
    1.25 +    if [ -n "$BINARY" ]; then
    1.26 +      echo "found $BINARY" >&2
    1.27 +      echo "$BINARY"
    1.28 +      return
    1.29 +    else
    1.30 +      echo "WARNING: $BASE not found!" >&2
    1.31 +      echo "$DEFAULT"
    1.32 +      return
    1.33 +    fi
    1.34 +  fi
    1.35 +}
    1.36 +
    1.37 +
    1.38 +## main
    1.39 +
    1.40 +BASH=$(findbin /bin/bash)
    1.41 +PERL=$(findbin /usr/bin/perl)
    1.42 +
    1.43 +for FILE in $(find . -type f -print)
    1.44 +do
    1.45 +  if [ -x "$FILE" ]; then
    1.46 +    sed -e "s:^#!.*/bash:#!$BASH:" -e "s:^#!.*/perl:#!$PERL:" $FILE >$FILE~~
    1.47 +    if cmp $FILE $FILE~~ -s; then
    1.48 +      rm $FILE~~
    1.49 +    else
    1.50 +      rm -f $FILE
    1.51 +      mv $FILE~~ $FILE
    1.52 +      chmod +x $FILE
    1.53 +      echo fixed $FILE
    1.54 +    fi
    1.55 +  fi
    1.56 +done