Problem
I coincidentally was trying to print a string to STDOUT
in gnome-terminal
that contains a lot of square brackets and noticed it took a lot of IO time (~4sec for ~100KB). To confirm that there is something specific about that string, I printed another string of the length, and the time is very different.
Specifically:
$ time cat file1
# ... snip ...
real 0m3.968s
user 0m0.004s
sys 0m0.001s
$ time cat file2
... snip ...
real 0m0.052s
user 0m0.006s
sys 0m0.001s
$ ls -l file*
-rw-rw-r-- 1 sinan sinan 115441 Dec 19 16:38 file1
-rw-rw-r-- 1 sinan sinan 115441 Dec 19 16:38 file2
I cannot tell what is the cause of the slowdown, I suspect something in gnome-terminal
parses square brackets and gives them a special meaning. Does anyone have any idea?
Version Information
gnome-terminal --version
:GNOME Terminal 3.36.2 using VTE 0.60.3 +BIDI +GNUTLS +ICU +SYSTEMD
bash --version
:GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
cat
. However, the terminal might be interested in doing syntax highligting or something similar. – Kusalananda Dec 19 '20 at 20:28PS1
which is the prompt. There are square-brackets e.g. for changing the title of the terminal and so on. – Marco Dec 24 '20 at 07:27printf "\e[8l"
(lasts up to areset
or so, you might want to embed it in your prompt), or globally as a hidden gnome-terminal setting, by navigatingdconf-editor
to/org/gnome/terminal/legacy/profiles:/:<the-profile-ID>/enable-bidi
. – egmont Mar 25 '21 at 00:36