From d0beb4cfec63481c7ecc4af75c3e2b86f7ed36f7 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 2 May 2009 14:45:48 +0400 Subject: [PATCH 1/3] src/main.c (main): create MC home directory (~/.mc) if absent. --- src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.c b/src/main.c index f8a6bb2af..767c4f48f 100644 --- a/src/main.c +++ b/src/main.c @@ -2121,6 +2121,9 @@ handle_args (int argc, char *argv[]) int main (int argc, char *argv[]) { + struct stat s; + char *mc_dir; + /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ setlocale (LC_ALL, ""); bindtextdomain ("mc", LOCALEDIR); @@ -2181,6 +2184,16 @@ main (int argc, char *argv[]) init_curses (); + /* create home directory */ + /* do it after the screen library initialization to show the error message */ + mc_dir = concat_dir_and_file (home_dir, MC_BASE); + canonicalize_pathname (mc_dir); + if ((stat (mc_dir, &s) != 0) && (errno == ENOENT) + && mkdir (mc_dir, 0755) != 0) + message (D_ERROR, _("Warning"), + _("Cannot create %s directory"), mc_dir); + g_free (mc_dir); + init_xterm_support (); #ifdef HAVE_SUBSHELL_SUPPORT From f7781c16e029c30aff92b3abe9e0e88640813a5f Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 2 May 2009 16:28:35 +0400 Subject: [PATCH 2/3] src/main.c (main): create MC home directory with 700 mode instead of 755 one. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 767c4f48f..bc9008b8a 100644 --- a/src/main.c +++ b/src/main.c @@ -2189,7 +2189,7 @@ main (int argc, char *argv[]) mc_dir = concat_dir_and_file (home_dir, MC_BASE); canonicalize_pathname (mc_dir); if ((stat (mc_dir, &s) != 0) && (errno == ENOENT) - && mkdir (mc_dir, 0755) != 0) + && mkdir (mc_dir, 0700) != 0) message (D_ERROR, _("Warning"), _("Cannot create %s directory"), mc_dir); g_free (mc_dir); From 9041e6c81f4b2ae15e7bc3f733016ec9250ea5aa Mon Sep 17 00:00:00 2001 From: "Mikhail S. Pobolovets" Date: Tue, 5 May 2009 16:46:10 +0300 Subject: [PATCH 3/3] commandline: strip_escape: strip xterm OSC commands in $PS1 Correctly deal with prompts like (appear in debian/ubuntu): PS1='\[\e]0;\u@\h: \w\a\]\u@\h:\w\$' PS1='\[\e]0;\u@\h: \w\e\\\]\u@\h:\w\$' Based on patch provided provided by Sergey Nizovtsev https://bugs.launchpad.net/ubuntu/+source/mc/+bug/330633 Signed-off-by: Sergei Trofimovich --- src/util.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/util.c b/src/util.c index 1f7150c6a..41f63c314 100644 --- a/src/util.c +++ b/src/util.c @@ -904,6 +904,34 @@ strip_ctrl_codes (char *s) if (*(++r) == '[') { /* strchr() matches trailing binary 0 */ while (*(++r) && strchr ("0123456789;?", *r)); + } else + if (*r == ']') { + /* + * Skip xterm's OSC (Operating System Command) + * http://www.xfree86.org/current/ctlseqs.html + * OSC P s ; P t ST + * OSC P s ; P t BEL + */ + char * new_r = r; + + for (; *new_r; ++new_r) + { + switch (*new_r) + { + /* BEL */ + case '\a': + r = new_r; + goto osc_out; + case ESC_CHAR: + /* ST */ + if (*(new_r + 1) == '\\') + { + r = new_r + 1; + goto osc_out; + } + } + } + osc_out:; } /*