#!/bin/bash
# Remove /bin or /usr/bin prefix from wrapped commands.

IFS=`printf '\n\t'`

unset SHELL
REALMAKESHELL="${REALMAKESHELL:=/bin/bash}"

if [ "$#" -eq 2 -a "$1" = "-c" ] ; then
  origcommand=`printf '%s' "$2" | sed -e 's/^ *//'`
  newcommand="$origcommand"
  newcommand="${newcommand#/usr/bin/}"
  newcommand="${newcommand#/bin/}"
  if [ "$newcommand" != "$origcommand" ] ; then
    commandname=`printf '%s' "$newcommand" | sed -e 's/[ \t].*//'`
    case "$commandname" in
      # This is the list of commands being redirected (alphabetically):
      chmod|cp|install|ln|mkdir|mv|touch)
        exec $REALMAKESHELL -c "$newcommand"
        ;;
    esac
  fi 
fi
exec $REALMAKESHELL "$@"

