bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] expanding $'\c^A'


From: Grisha Levit
Subject: [PATCH] expanding $'\c^A'
Date: Thu, 12 Oct 2023 21:36:55 -0700

Handle $'\c^A' and $'\c^?' correctly when expanded by the parser:

$ bash -c $'printf "%q\n" $\'\\c\001 \\c\177\''
$'\001\001 \001\177'

---
diff --git a/lib/sh/strtrans.c b/lib/sh/strtrans.c
index d3b27f3b..3df33ade 100644
--- a/lib/sh/strtrans.c
+++ b/lib/sh/strtrans.c
@@ -198,6 +198,8 @@ ansicstr (const char *string, size_t len, int
flags, int *sawc, size_t *rlen)
    s++;
    if ((flags & 2) && c == '\\' && c == *s)
      s++; /* Posix requires $'\c\\' do backslash escaping */
+   else if ((flags & 2) && c == CTLESC && (*s == CTLESC || *s == CTLNUL))
+     s++;
    c = TOCTRL(c);
    break;
  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]