about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c13
-rw-r--r--Src/hist.c6
2 files changed, 19 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 1c44565f9..de1b4848e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1845,9 +1845,22 @@ quote_tokenized_output(char *str, FILE *file)
 	case '*':
 	case '?':
 	case '$':
+	case ' ':
 	    putc('\\', file);
 	    break;
 
+	case '\t':
+	    fputs("$'\\t'", file);
+	    continue;
+
+	case '\n':
+	    fputs("$'\\n'", file);
+	    continue;
+
+	case '\r':
+	    fputs("$'\\r'", file);
+	    continue;
+
 	case '=':
 	    if (s == str)
 		putc('\\', file);
diff --git a/Src/hist.c b/Src/hist.c
index d1af30a29..bd650e81e 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -521,6 +521,12 @@ histsubchar(int c)
 		}
 		c = ingetc();
 	    }
+	    if (ptr == buf &&
+		(c == '}' ||  c == ';' || c == '\'' || c == '"' || c == '`')) {
+	      /* Neither event nor word designator, no expansion */
+	      safeinungetc(c);
+	      return bangchar;
+	    }
 	    *ptr = 0;
 	    if (!*buf) {
 		if (c != '%') {