C
C
CityCat42017-03-16 15:07:14
linux
CityCat4, 2017-03-16 15:07:14

Why does mc throw an error when entering a directory with a space in the name?

All this is done on the command line of the running mc.
I create a directory with a space in the name:
# mkdir '/tmp/test test2'
Creates normally. I'm trying to go into it:
# cd '/tmp/test test2'
mc throws out a red window with a message that the directory was not found. If you go to it by pressing 'enter' on the directory will display the message "Warning: cannot change to /tmp/test test2", but the directory's table of contents will show you can copy and delete files - from the panels. When trying to execute any command through the command line, the command is ignored, thrown into the top-level directory.
wtf?
mc 4.8.19, ext4

# uname -a
Linux geobase0 4.4.39-calculate #1 SMP PREEMPT Fri Jan 13 13:45:12 UTC 2017 x86_64 Intel(R) Core(TM) i7-5960X CPU @ 3.00GHz GenuineIntel GNU/Linux

UPD: This all happens if the login-shell is tcsh, if the login-shell is bash, no error occurs. Because tcsh is somehow specially processed in subshell.c, why is not clear yet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-03-16
@saboteur_kiev

And so:
cd /tmp/test\ test2

C
CityCat4, 2017-03-17
@CityCat4

It's getting weirder and weirder...
This fucking message is issued by the following code:

if (bPathNotEq && mc_global.shell->type == SHELL_TCSH)
        {
            char rp_subshell_cwd[PATH_MAX];
            char rp_current_panel_cwd[PATH_MAX];
            char *p_subshell_cwd, *p_current_panel_cwd;

            p_subshell_cwd = mc_realpath (subshell_cwd, rp_subshell_cwd);
            p_current_panel_cwd = mc_realpath (pcwd, rp_current_panel_cwd);

            if (p_subshell_cwd == NULL)
                p_subshell_cwd = subshell_cwd;
            if (p_current_panel_cwd == NULL)
                p_current_panel_cwd = pcwd;
            bPathNotEq = strcmp (p_subshell_cwd, p_current_panel_cwd) != 0;
        }

        if (bPathNotEq && !DIR_IS_DOT (pcwd))
        {
            char *cwd;

            cwd =
                vfs_path_to_str_flags (subshell_get_cwd_from_current_panel (), 0,
                                       VPF_STRIP_PASSWORD);
            vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd);
            g_free (cwd);
        }

Here, subshell_cwd is filled with a call to feed_subshell() and pcwd is filled with a call to subshell_get_cwd_from_current_panel(). The first contains the wrong value, the second is correct. Naturally, the condition works and bamts. subshell_cwd in feed_subshell() is populated via standard read():
And here I've blunted so far - if mc is launched from tcsh, then read, having found the name of the directory with a space, reads up to the nearest slash! . If from bash - reads exactly as much as necessary. wtf?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question