mc/mcfn_install.in
Norbert Warmuth 10c8184839 1999-09-22 Bjorn Eriksson <mdeans@algonet.se>
* vfs/extfs/uzip.in: Better handling of zip-archives that contain files
which contain spaces.


1999-09-22  Norbert Warmuth  <nwarmuth@privat.circular.de>

* lib/mc.sh.in, mc.csh.in: renamed from mc.sh resp. mc.csh. Adapt
path to the mc binary according to @prefix@.

* lib/Makefile.in (srcdir): mc.sh and mc.csh are now created by
configure. Install mc.sh and mc.csh in $(suppbindir).

* doc/mc.1.in, mc.sgml: Updated the mc function definition for bash
and zsh. Suggest to source mc.sh or mc.csh instead of adding verbatim
copies of the included function definitions.

* mcfn_install.in: Comment out definitions of the mc functions. Source
mc.sh instead of adding an outdated mc function definition.

* configure.in: output mc.sh and mc.csh
1999-09-22 22:04:45 +00:00

137 lines
3.4 KiB
Bash

#!/bin/sh
#
prefix=@prefix@
suppbindir=@prefix@/lib/mc/bin
do_compat_replace () {
cp $1 $1.orig
if test "$?" != "0"; then
echo "Command \`cp $1 $1.orig' failed. File $1 not changed!"
return 1
fi
sed '/^mc ()/ {
# Add comment
i\
#Commented out by mc_fninstall. Source @prefix@/lib/mc/bin/mc.sh instead.
}
/^mc ()[^}]*$/,/}[; ]*$/{
# Function definition over several lines
s/^\(.*\)$/#\1/g
}
/^mc ().*}.*$/{
# Function definition on one line
s/^\(.*\)$/#\1/g
}' < $1.orig > $1
echo >> $1
echo ". $suppbindir/mc.sh" >> $1
echo ""
echo "I commented out the mc () function definitions in $1 and added"
echo "\`. $suppbindir/mc.sh'. Your previous profile has been saved as"
echo "$1.orig."
}
if test -n `echo $prefix | grep prefix`; then
prefix=/usr/local
fi
if test x$BASH = x; then
BASHRC=
else
BASHRC=~/.bashrc
fi
if test "x$EUID" = x0; then
PROFILE=/etc/profile
else
PROFILE=~/.profile
fi
if test -f $PROFILE; then
A=`grep "mc ()" $PROFILE`
B=
if test -n "$BASHRC"; then
if test -f $BASHRC; then
B=`grep "mc ()" $BASHRC`
fi
fi
if test -n "$A" -o -n "$B"; then
if test -n "$B"; then
echo "While examining your $PROFILE and $BASHRC,"
else
echo "While examining your $PROFILE,"
fi
echo "I've found that you have a probably outdated mc () function definition"
echo "there. Do you want to replace this function definition with "
echo " . $suppbindir/mc.sh"
read rep
case $rep in
[Yy]*) ;;
*) exit ;;
esac
if test -n "$A"; then
do_compat_replace $PROFILE
fi
if test -n "$B"; then
do_compat_replace $BASHRC
fi
exit 0
fi
unset -f do_compat_replace
# This doesn't handle the case that $prefix changed
A=`grep "/mc.sh" $PROFILE`
B=
if test -n "$BASHRC"; then
if test -f $BASHRC; then
B=`grep "/mc.sh" $BASHRC`
fi
fi
if test -n "$A"; then
:
else
if test -n "$B"; then
:
else
A=`typeset -f | grep "mc ()" 2>/dev/null`
if test ! -n "$A"; then
echo "mc () installation."
if test -n "$BASHRC"; then
echo "While examining your $PROFILE and $BASHRC,"
else
echo "While examining your $PROFILE,"
fi
echo "I've found that you do not source $suppbindir/mc.sh there."
echo "This shell script defines a function which enables a feature of mc(1)"
echo "that when you leave mc(1), you return to a directory where you were"
echo "in mc just before exiting and not to the directory you've started mc"
echo "from."
echo "Would you like to append"
echo "test -f $suppbindir/mc.sh && . $suppbindir/mc.sh"
if test -n "$BASHRC"; then
echo "to your (p) $PROFILE (mc function will be active in your login shells)"
echo -n "or to your (b) $BASHRC (in every bash instance) or (n) no? [p|b|n] "
else
echo -n "function to your $PROFILE? [y|n] "
fi
read rep
if test -n "$BASHRC"; then
INITFILE=$BASHRC
else
INITFILE=$PROFILE
fi
case $rep in
[Yy]*) ;;
[Pp]*) INITFILE=$PROFILE ;;
*) exit 1;;
esac
echo >>$INITFILE
echo 'test -f $suppbindir/mc.sh && . $suppbindir/mc.sh' >>$INITFILE
echo "mc () function appended to your $INITFILE"
fi
fi
fi
fi