Subject: bash 3.2 , echo -e and mc (error warning cannot change directory)
To: None <pkgsrc-users@NetBSD.org>
From: stefanos mparas <stefano@arx.net>
List: pkgsrc-users
Date: 12/21/2007 13:45:06
This is a multi-part message in MIME format.
--------------070207060102050603080106
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

hello ,

few days ago i rebuild and reinstalled all pkgsrc packages (cvs from a 
week ago)
but
every now and then i got errors from MC ( midnight commander)
when trying to change to a directory ( mostly when the directory 
contained '-' '_' and such other characters )
after a little google search i found that there used to be a problem 
with the combination of

bash-3.2   ( installed on my system)
echo built in command
mc-4.6.1 (installed , way of managing directory names )


particularly echo changed behavior for echo -e '\nnn'

it seems that :

Bash 3.1 says:   \num    the character whose ASCII code is NUM (octal)
Bash 3.2 says:   \0nnn   the character whose ASCII code is NNN (octal).
                         NNN can be 0 to 3 octal digits


so mc gets choked ,

after a little more search found a patch to fix this (attached)
i tried it for a few hours and it works

could someone have a look on it and if it's ok apply it ?

stefano

references :
http://www.mail-archive.com/bug-bash@gnu.org/msg02150.html
http://bugs.gentoo.org/show_bug.cgi?id=153925
http://bugs.gentoo.org/attachment.cgi?id=101796&action=view









--------------070207060102050603080106
Content-Type: text/plain;
 name="patch.for.mc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch.for.mc"

--- subshell.c.orig	2005-06-07 12:19:19.000000000 +0300
+++ subshell.c	2007-12-21 13:08:23.000000000 +0200
@@ -718,29 +718,13 @@
     memcpy (d, cmd_start, len);
     d += len;
 
-    /*
-     * Print every character in octal format with the leading backslash.
-     * tcsh and zsh may require 4-digit octals, bash < 2.05b doesn't like them.
-     */
-    if (subshell_type == BASH) {
 	for (; *s; s++) {
-	    /* Must quote numbers, so that they are not glued to octals */
 	    if (isalpha ((unsigned char) *s)) {
 		*d++ = (unsigned char) *s;
 	    } else {
-		sprintf (d, "\\%03o", (unsigned char) *s);
-		d += 4;
-	    }
-	}
-    } else {
-	for (; *s; s++) {
-	    if (isalnum ((unsigned char) *s)) {
-		*d++ = (unsigned char) *s;
-	    } else {
 		sprintf (d, "\\0%03o", (unsigned char) *s);
 		d += 5;
 	    }
-	}
     }
 
     memcpy (d, common_end, sizeof (common_end));

--------------070207060102050603080106--