Skip to content

Commit 3164310

Browse files
committed
Avoid printf in __vsc_report_prompt
Fixes #212090
1 parent 89de5a8 commit 3164310

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,44 @@ __vsc_escape_value() {
116116

117117
for (( i=0; i < "${#str}"; ++i )); do
118118
byte="${str:$i:1}"
119-
120-
# Escape backslashes, semi-colons specially, then special ASCII chars below space (0x20)
119+
# Escape backslashes, semi-colons specially, then special ASCII chars below space (0x20).
120+
# This is done in an unwrapped loop instead of using printf as the latter is very slow.
121121
if [ "$byte" = "\\" ]; then
122122
token="\\\\"
123123
elif [ "$byte" = ";" ]; then
124124
token="\\x3b"
125-
elif (( $(builtin printf '%d' "'$byte") < 31 )); then
126-
token=$(builtin printf '\\x%02x' "'$byte")
125+
elif [ "$byte" = $'\x00' ]; then token="\\x00"
126+
elif [ "$byte" = $'\x01' ]; then token="\\x01"
127+
elif [ "$byte" = $'\x02' ]; then token="\\x02"
128+
elif [ "$byte" = $'\x03' ]; then token="\\x03"
129+
elif [ "$byte" = $'\x04' ]; then token="\\x04"
130+
elif [ "$byte" = $'\x05' ]; then token="\\x05"
131+
elif [ "$byte" = $'\x06' ]; then token="\\x06"
132+
elif [ "$byte" = $'\x07' ]; then token="\\x07"
133+
elif [ "$byte" = $'\x08' ]; then token="\\x08"
134+
elif [ "$byte" = $'\x09' ]; then token="\\x09"
135+
elif [ "$byte" = $'\x0a' ]; then token="\\x0a"
136+
elif [ "$byte" = $'\x0b' ]; then token="\\x0b"
137+
elif [ "$byte" = $'\x0c' ]; then token="\\x0c"
138+
elif [ "$byte" = $'\x0d' ]; then token="\\x0d"
139+
elif [ "$byte" = $'\x0e' ]; then token="\\x0e"
140+
elif [ "$byte" = $'\x0f' ]; then token="\\x0f"
141+
elif [ "$byte" = $'\x10' ]; then token="\\x10"
142+
elif [ "$byte" = $'\x11' ]; then token="\\x11"
143+
elif [ "$byte" = $'\x12' ]; then token="\\x12"
144+
elif [ "$byte" = $'\x13' ]; then token="\\x13"
145+
elif [ "$byte" = $'\x14' ]; then token="\\x14"
146+
elif [ "$byte" = $'\x15' ]; then token="\\x15"
147+
elif [ "$byte" = $'\x16' ]; then token="\\x16"
148+
elif [ "$byte" = $'\x17' ]; then token="\\x17"
149+
elif [ "$byte" = $'\x18' ]; then token="\\x18"
150+
elif [ "$byte" = $'\x19' ]; then token="\\x19"
151+
elif [ "$byte" = $'\x1a' ]; then token="\\x1a"
152+
elif [ "$byte" = $'\x1b' ]; then token="\\x1b"
153+
elif [ "$byte" = $'\x1c' ]; then token="\\x1c"
154+
elif [ "$byte" = $'\x1d' ]; then token="\\x1d"
155+
elif [ "$byte" = $'\x1e' ]; then token="\\x1e"
156+
elif [ "$byte" = $'\x1f' ]; then token="\\x1f"
127157
else
128158
token="$byte"
129159
fi

0 commit comments

Comments
 (0)