#!bash
#
# supported versions of install-info
#   These version's command line spec is different...
#   1)install-info 1.6.x (Debian (potato) system.)
#   2)install-info 1.9.x (Debian (woody)  system.)
#   3)install-info 4.x   (cygwin and almost Emacs application use this.)

PATH=/sbin:/usr/sbin:$PATH

if [[ $# < 2 ]] ; then
  echo "usage) install-info infofile infodir [option]"
  exit 1;
fi

install-info --version &> ./tmp.log
ver=`head -1 ./tmp.log | sed -e 's/^\(.*\)\( 1\.[0-9]\)\(.*\)$/\2/'`
/bin/rm ./tmp.log

case $3 in
  "remove")
    case $ver in
      " 1.6")
        install-info --info-dir=`dirname $2` --remove $1
        ;;
      " 1.9")
        install-info --info-dir=`dirname $2` --remove-exactly $1
        ;;
      *)
        install-info --remove $1 $2
        ;;
    esac
    ;;
  *)
    case $ver in
      " 1.6")
        install-info --info-dir=`dirname $2` --section=Emacs $1
        ;;
      " 1.9")
        install-info --info-dir=`dirname $2` --section Emacs Emacs $1
        ;;
      *)
        install-info $1 $2
        ;;
    esac
    ;;
esac
exit 0;
