Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 4801 - small fix for midnight commander
Summary: small fix for midnight commander
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Michael M Nazaroff (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-10 05:13 UTC by Alessandro Pisani
Modified: 2003-05-06 11:43 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Pisani 2002-07-10 05:13:09 UTC
removing line:
export -f mc
from /usr/lib/mc/mc.sh will allow the script to be loaded from .bashrc (giving
you changedir capability, i mean: mc will chdir to its latest working dir at
exit) without having portage to spurt out warning during emerge.
Comment 1 Michael M Nazaroff (RETIRED) gentoo-dev 2002-07-13 17:16:12 UTC
Ok I really don't think I understand what you want to do here?  Are you also
talking about /usr/lib/mc/bin/mc.sh right? since there isn't mc.sh in
/usr/lib/mc.. and what warning are you getting?
Comment 2 Alessandro Pisani 2002-07-14 03:17:05 UTC
mc.sh is provided in /usr/lib/mc/bin. I modified my ~/.bashrc to load also mc.sh (as it happen on RedHat) ; this change allows MC to change directory to the last one used into MC as you exit MC. (you invoke mc into /usr, then into MC you move to /etc and exit MC, you now are in /etc). Problem is that gentoo's mc.sh have and  "export -f mc" line at bottom of it which causes the mc alias function to be sourced into env; this will cause portage generate warnings every time you emerge a package. infact, loading mc.sh via .bashrc will perfectly work without the "export -f mc". i can supply my scripts to let you understand, if needed. and oh, yes, this is really a "cosmetic" fix.  HTH 
Comment 3 Alessandro Pisani 2002-07-14 06:42:56 UTC
oops...mouse wheel made konqueror change forms...restoring bug as "normal" and "opened" . sorry.  
Comment 4 Michael M Nazaroff (RETIRED) gentoo-dev 2002-07-14 07:11:12 UTC
Yeah just send it to me please and maybe a sample of anything else to get it
working .. the appropriate lines from .bashrc? maybe

naz
Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-03 04:54:00 UTC
Whats up here ?
Comment 6 Alessandro Pisani 2002-12-04 11:25:34 UTC
Martin: I don't know, i sent my fix to Michael in july...and that's all :)
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-04 14:47:27 UTC
Hrm .. problem is that we do not have a /etc/profile.d/ ... Another way is
to create a /usr/bin/mc wrapper that sources that, and then calls say 
/usr/bin/mc-bin
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-06 02:10:18 UTC
Alessandro, any suggestions ?  Would the wrapper resolve the issue ?
Comment 9 Alessandro Pisani 2002-12-06 10:24:44 UTC
don't know : i tried the wrapper some time ago and it didn't work... btw i'll
check it as soon as I'll be able to resurrect my gentoo hd (rad: probably on
monday/tuesday), which is currently down due to an hardware failure (damn!).

bye!
alessandro
Comment 10 Alessandro Pisani 2002-12-17 08:49:57 UTC
just tested: no, the wrapper thing won't work :(
if someone want to use my solution on his own i can attach here a tar.gz with
all the needed files (basically: /etc/profile.d/mc.sh, /etc/bashrc and a
modified /etc/skel/.bashrc which needs to be copied to ~/.bashrc)

bye,
Alessandro
Comment 11 Michael M Nazaroff (RETIRED) gentoo-dev 2002-12-19 11:47:27 UTC
Dang, I can't find the files you sent me, it seems that there should a easy way
around this issue, just need to apply some thought
Comment 12 Alessandro Pisani 2002-12-19 12:00:39 UTC
Michael: i can send you the .tar.gz again, if you want.... or better: i'm gonna
dump them here:

1: /etc/bashrc

---->
# /etc/bashrc

for i in /etc/profile.d/*.sh; do
        if [ -x $i ]; then
            . $i
        fi
done

# include this, so also xterm,kterm,gterm,etc will have default bash settings
if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
            source /etc/profile
fi

# vim:ts=4:sw=4
<----


2: /etc/profile.d (directory)

3: /etc/profile.d/mc.sh (<- please note: this is NOT the same as
/usr/lib/mc/bin/mc.sh since it won't work)

--->
# this is a slightly modified version of /usr/lib/mc/mc.sh which fixes
# problems with portage when this script is included into the bash env

mc ()
{
    mkdir -p $HOME/.mc/tmp 2> /dev/null
    chmod 700 $HOME/.mc/tmp
    MC=$HOME/.mc/tmp/mc-$$
    /usr/bin/mc -P "$@" > "$MC"
    cd "`cat $MC`"
    rm -f "$MC"
    unset MC;
}
<---

4: add this at bottom of /etc/skel/.bashrc  (and so also my ~/.bashrc )

---->
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
<----


HTH,
Alessandro
Comment 13 Michael M Nazaroff (RETIRED) gentoo-dev 2002-12-20 13:23:57 UTC
Well I created a file in /etc/ called mc.env which contains:

# /etc/mc.env

# This variable can be set to mc.sh or mc.csh depending on your shell.
MC_ENV=/usr/lib/mc/bin/mc.sh

for i in $MC_ENV; do
        if [ -x $i ]; then
                . $i
        fi
done

# include this, so also xterm,kterm,gterm,etc will have default bash settings

if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
        source /etc/profile
fi

With that completed I copied /usr/lib/mc/bin/mc.sh to mc.sh.bak and edited out
export line then sourced it from with .bashrc which contains

if [ -f /etc/mc.env ]; then
    . /etc/mc.env
fi

This seems to work ok for me.  Care to test? I'm thinking that maybe we should
maybe consider setting a enviroment variable with a script in env.d which will
just source in the fixed mc.sh script.  I'm not sure if that will work.. but I
will test in a little bit.
Comment 14 Alessandro Pisani 2002-12-20 14:26:28 UTC
tested: your solution work as expected... btw, i like the env.d idea much better
since users wouldn't have to mess up their .bashrc

bye,
Alessandro
Comment 15 Michael M Nazaroff (RETIRED) gentoo-dev 2003-05-06 06:20:05 UTC
Commited to additions to portage for testing.

Naz
Comment 16 Alessandro Pisani 2003-05-06 08:05:16 UTC
please note that mc 4.6.x needs a slighlty different syntax:
instead of:     /usr/bin/mc -P "$@" > "$MC"
use:   /usr/bin/mc -P "$MC"

bye,
Alessandro
Comment 17 Alessandro Pisani 2003-05-06 11:43:23 UTC
Michael : just checked it: please change syntax of the file as suggested in comment #16 sinec the current one is wrong in mc 4.6.0 (it will cause mc to crash on startup using -P "$@" > "$MC"  instead of the new  -P "$MC"

alessandro