* editmenu.c (edit_wrap_cmd): Use g_free() on the result
[midnight-commander.git] / mcfn_install.in
blob9cf99c7d1ca439fed4ed58d74ed3db4ea8fc0d7c
1 #!/bin/sh
4 prefix=@prefix@
5 suppbindir=@prefix@/lib/mc/bin
7 do_compat_replace () {
8 cp $1 $1.orig
9 if test "$?" != "0"; then
10 echo "Command \`cp $1 $1.orig' failed. File $1 not changed!"
11 return 1
13 sed '/^mc ()/ {
14 # Add comment
16 #Commented out by mc_fninstall. Source @prefix@/lib/mc/bin/mc.sh instead.
19 /^mc ()[^}]*$/,/}[; ]*$/{
20 # Function definition over several lines
21 s/^\(.*\)$/#\1/g
24 /^mc ().*}.*$/{
25 # Function definition on one line
26 s/^\(.*\)$/#\1/g
27 }' < $1.orig > $1
29 echo >> $1
30 echo ". $suppbindir/mc.sh" >> $1
31 echo ""
32 echo "I commented out the mc () function definitions in $1 and added"
33 echo "\`. $suppbindir/mc.sh'. Your previous profile has been saved as"
34 echo "$1.orig."
37 if test -n `echo $prefix | grep prefix`; then
38 prefix=/usr/local
40 if test x$BASH = x; then
41 BASHRC=
42 else
43 BASHRC=~/.bashrc
45 if test "x$EUID" = x0; then
46 PROFILE=/etc/profile
47 else
48 PROFILE=~/.profile
50 if test -f $PROFILE; then
51 A=`grep "mc ()" $PROFILE`
53 if test -n "$BASHRC"; then
54 if test -f $BASHRC; then
55 B=`grep "mc ()" $BASHRC`
59 if test -n "$A" -o -n "$B"; then
60 if test -n "$B"; then
61 echo "While examining your $PROFILE and $BASHRC,"
62 else
63 echo "While examining your $PROFILE,"
65 echo "I've found that you have a probably outdated mc () function definition"
66 echo "there. Do you want to replace this function definition with "
67 echo " . $suppbindir/mc.sh"
68 read rep
69 case $rep in
70 [Yy]*) ;;
71 *) exit ;;
72 esac
73 if test -n "$A"; then
74 do_compat_replace $PROFILE
76 if test -n "$B"; then
77 do_compat_replace $BASHRC
80 exit 0
82 unset -f do_compat_replace
84 # This doesn't handle the case that $prefix changed
85 A=`grep "/mc.sh" $PROFILE`
87 if test -n "$BASHRC"; then
88 if test -f $BASHRC; then
89 B=`grep "/mc.sh" $BASHRC`
92 if test -n "$A"; then
94 else
95 if test -n "$B"; then
97 else
98 A=`typeset -f | grep "mc ()" 2>/dev/null`
99 if test ! -n "$A"; then
100 echo "mc () installation."
101 if test -n "$BASHRC"; then
102 echo "While examining your $PROFILE and $BASHRC,"
103 else
104 echo "While examining your $PROFILE,"
106 echo "I've found that you do not source $suppbindir/mc.sh there."
107 echo "This shell script defines a function which enables a feature of mc(1)"
108 echo "that when you leave mc(1), you return to a directory where you were"
109 echo "in mc just before exiting and not to the directory you've started mc"
110 echo "from."
111 echo "Would you like to append"
112 echo "test -f $suppbindir/mc.sh && . $suppbindir/mc.sh"
113 if test -n "$BASHRC"; then
114 echo "to your (p) $PROFILE (mc function will be active in your login shells)"
115 echo -n "or to your (b) $BASHRC (in every bash instance) or (n) no? [p|b|n] "
116 else
117 echo -n "function to your $PROFILE? [y|n] "
119 read rep
120 if test -n "$BASHRC"; then
121 INITFILE=$BASHRC
122 else
123 INITFILE=$PROFILE
125 case $rep in
126 [Yy]*) ;;
127 [Pp]*) INITFILE=$PROFILE ;;
128 *) exit 1;;
129 esac
130 echo >>$INITFILE
131 echo 'test -f $suppbindir/mc.sh && . $suppbindir/mc.sh' >>$INITFILE
132 echo "mc () function appended to your $INITFILE"