Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently installed openSUSE 13.1 and set up the mc in typical why by aliasing mc with to have it exit into the last working directory in mc instance. However this does not seem to be working. I tried to debug the script - the echo commands.

MC_USER=`id | sed 's/[^(]*(//;s/).*//'`
/usr/bin/mc -P "$MC_PWD_FILE" "$@"

if test -r "$MC_PWD_FILE"; then
        MC_PWD="`cat "$MC_PWD_FILE"`"
        if test -n "$MC_PWD" && test -d "$MC_PWD"; then
                echo "will cd in : $MC_PWD"
                cd $MC_PWD
                echo $(pwd)
        unset MC_PWD

rm -f "$MC_PWD_FILE"
echo $(pwd)

To my surprise, mc-wrapper-sh does change the directory and is in the directory before exiting but back in bash prompt the working directory is the one from which the script was invoked.

Can it be that some bash settings is required for this to work?

share|improve this question
Your script runs as new process with its own environment and can not change the environment of the calling shell. You can only change working directory of your shell if you source your script: source name_of_your_script. – Cyrus Jul 12 '14 at 19:31
@Cyrus Please provide this as an answer, as this solved the same problem for me. – Marcel Korpel Jul 15 '15 at 0:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.