Skip to content

Instantly share code, notes, and snippets.

@andreipak
Last active December 26, 2015 18:19
Show Gist options
  • Save andreipak/7193285 to your computer and use it in GitHub Desktop.
Save andreipak/7193285 to your computer and use it in GitHub Desktop.
MC clobbers the PROMPT_COMMAND shell variable [http://www.midnight-commander.org/ticket/2027]
diff -udpr src/subshell.c.orig src/subshell.c
--- src/subshell.c.orig 2013-08-02 18:02:39.000000000 +0300
+++ src/subshell.c 2013-10-28 10:47:34.000000000 +0200
@@ -769,7 +769,7 @@ init_subshell (void)
{
/* This must be remembered across calls to init_subshell() */
static char pty_name[BUF_SMALL];
- char precmd[BUF_SMALL];
+ char precmd[BUF_MEDIUM];
switch (check_sid ())
{
@@ -884,7 +884,7 @@ init_subshell (void)
{
case BASH:
g_snprintf (precmd, sizeof (precmd),
- " PROMPT_COMMAND='pwd>&%d;kill -STOP $$'\n", subshell_pipe[WRITE]);
+ " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'pwd>&%d;kill -STOP $$'\n", subshell_pipe[WRITE]);
break;
case ZSH:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment