$ v=$'\1\1'; printf '%q\n' "${v@E}" $'\001' call ansicstr directly instead of through ansiexpand so we don't end up trimming existing CTLESC CTLESC in the string with dequote_escapes --- subst.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/subst.c b/subst.c index 855ff745..4b289021 100644 --- a/subst.c +++ b/subst.c @@ -8603,7 +8603,7 @@ pos_params_assignment (WORD_LIST *list, int itype, int quoted) static char * string_transform (int xc, SHELL_VAR *v, char *s) { - char *ret, flags[MAX_ATTRIBUTES], *t; + char *ret, flags[MAX_ATTRIBUTES]; int i; if (((xc == 'A' || xc == 'a') && v == 0)) @@ -8627,9 +8627,7 @@ string_transform (int xc, SHELL_VAR *v, char *s) break; /* Transformations that modify the variable's value */ case 'E': - t = ansiexpand (s, 0, strlen (s), 0); - ret = dequote_escapes (t); - free (t); + ret = ansicstr (s, strlen (s), 0, 0, 0); break; case 'P': ret = decode_prompt_string (s); -- 2.42.0