patch-scripts.bash
author paulson
Tue, 10 Dec 1996 15:08:57 +0100
changeset 2371 c5dc6f8b385b
parent 2350 da4f8b250e1a
child 2475 36bdba95e170
permissions -rw-r--r--
Now target "test" builds and tests TFL

#
# $Id$
#
# patch-scripts.bash - relocate interpreter paths of Isabelle scripts.
#

## find binaries

function findbin()
{
  local DEFAULT="$1"
  local BASE=""
  local BINARY=""

  if [ -f "$DEFAULT" ]; then	# preferred location
    echo "found $DEFAULT" >&2
    echo "$DEFAULT"
    return
  else				# find in PATH
    BASE=$(basename "$DEFAULT")
    BINARY=$(type -path "$BASE")
    if [ -n "$BINARY" ]; then
      echo "found $BINARY" >&2
      echo "$BINARY"
      return
    else
      echo "WARNING: $BASE not found!" >&2
      echo "$DEFAULT"
      return
    fi
  fi
}


## main

BASH=$(findbin /bin/bash)
PERL=$(findbin /usr/bin/perl)

for FILE in $(find . -type f -print)
do
  if [ -x "$FILE" ]; then
    sed -e "s:^#!.*/bash:#!$BASH:" -e "s:^#!.*/perl:#!$PERL:" $FILE >$FILE~~
    if cmp $FILE $FILE~~ -s; then
      rm $FILE~~
    else
      rm -f $FILE
      mv $FILE~~ $FILE
      chmod +x $FILE
      echo fixed $FILE
    fi
  fi
done