Browse Source

When modifiers \ and # is on - don't escape_chars

git-svn-id: https://klish.googlecode.com/svn/trunk@540 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 12 years ago
parent
commit
a9748a7bc5
1 changed files with 9 additions and 4 deletions
  1. 9 4
      clish/shell/shell_var.c

+ 9 - 4
clish/shell/shell_var.c

@@ -210,7 +210,8 @@ static char *expand_nextsegment(const char **string, const char *escape_chars,
 				q; q = strtok_r(NULL, ":", &saveptr)) {
 				char *var;
 				int mod_quote = 0; /* quote modifier */
-				int mod_esc = 0; /* escape modifier */
+				int mod_esc = 0; /* internal escape modifier */
+				int mod_esc_chars = 1; /* escaping */
 				char *space;
 				char *all_esc = NULL;
 
@@ -219,9 +220,11 @@ static char *expand_nextsegment(const char **string, const char *escape_chars,
 					if ('#' == *q) {
 						mod_quote = 1;
 						mod_esc = 1;
-					} else if ('\\' == *q)
+						mod_esc_chars = 0;
+					} else if ('\\' == *q) {
 						mod_esc = 1;
-					else
+						mod_esc_chars = 0;
+					} else
 						break;
 					q++;
 				}
@@ -246,8 +249,10 @@ static char *expand_nextsegment(const char **string, const char *escape_chars,
 						lub_string_esc_quoted);
 
 				/* Escape special chars */
-				if (escape_chars)
+				if (escape_chars && mod_esc_chars)
 					lub_string_cat(&all_esc, escape_chars);
+
+				/* Real escaping */
 				if (all_esc) {
 					char *tstr = lub_string_encode(var,
 						all_esc);