#! /usr/bin/ksh export LC_ALL=C export PATH=/usr/bin:/bin cfg=/etc/vac.cfg targbin=/usr/vac/bin/xlc sysbin=/usr/bin targman=/usr/vac/exe/default_msg/vac.help extman=.1 # Determine the stanza names from the config file stanzas=`sed -ne '/^DEFLT:/ d' -e '/^[a-zA-Z0-9_]*:/ { s/:.*$// p }' -- "$cfg"` || { print -u2 "Cannot determine compiler invocation names from $cfg." exit 1 } [[ -n $stanzas ]] || { print -u2 "No compiler invocation names were found in $cfg." exit 1 } # replace(name,link-target) function replace { [[ -e $1 ]] && { [[ -e $saved/${1##*/} ]] && { if cmp -s -- "$1" "$2"; then print -u1 -- "$1 has already been replaced." return 0 elif cmp -s -- "$1" "$saved/${1##*/}"; then # degenerate case, /usr/bin is a dup of saved copy rm -f -- "$1" || { return 1 } else print -u2 "ERROR: $saved/${1##*/} already exists." print -u2 " $1 can not be replaced." return 1 fi } print -u1 "Replacing $1" mv -- "$1" "$saved/${1##*/}" || { print -u2 "ERROR: Problems saving $1, skipping." return 1 } } ln -s -- "$2" "$1" || { return 1 } return 0 } fail=0 for cmd in $stanzas; do replace $sysbin/$cmd $targbin || fail=1 done exit $fail