bug-bash
[Top][All Lists]
Advanced

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

Bash not escaping escape sequences in directory names


From: Josh Harcombe
Subject: Bash not escaping escape sequences in directory names
Date: Wed, 19 Jan 2022 13:13:53 +1100

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux computator 5.10.89-1-MANJARO #1 SMP PREEMPT Wed Dec 29
18:09:17 UTC 2021 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: !PATCHLEVEL!
Release Status: alpha

Description:
Note: this happens on 5.1 release version as well and probably many other
previous versions
If a folder that is being displayed as part of the PS1 prompt contains
escape sequences, bash will interpret them literally instead of escaping
them like zsh does for example. Escape sequences should be fine if directly
part of the prompt string and I'm not aware of any way for this to cause
issues other than messing with the prompt string in potentially unexpected
ways.
I would consider this a bug but it's possible there's an intended use case
for it.

Repeat-By:
This is a silly little use case which gives the illusion of a root shell,
with the colours changed and the end of the original prompt hidden.

[computator ~]$ echo -e "\"\r\x1b[1;31m[computator
\x1b[1;36mjoshh\x1b[1;31m]#\x1b[0;37m\x1b[8m\"" | xargs mkdir
[computator ~]$ cd ^M^[\[1\;31m\[computator\
^[\[1\;36mjoshh^[\[1\;31m\]#^[\[0\;37m^[\[8m/
[computator joshh]#

Fix:
Haven't looked deeply into the bash internals but sanitizing the directory
name (along with other user-controlled substitutions in the prompt) should
work.


reply via email to

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