Ah, of course. Test should not be counted as a visible character and should be included between \[
and \]
.
Working example:
export PS1="prompt>\[\033[s\033[10Ctest\033[u\]"
The reason was because if bash count test as a visible character it will assume it's left if the cursor and the calculation of available characters left on the current line will be off by four characters (length of 'test').
In string:
rtsp://user:pass@my.webserver.org:5554/my-media/media.amp?videocodec=h264
you have ?
in that string, so the shell will perform pathname expansion on that string, using pattern matching rules.
In bash
, if failglob
options was not set, which is default, then failed pattern will be left as-is:
$ echo does-not-exist?
does-not-exist?
While zsh
will report no pattern match error with nomatch
option set, which is default:
$ echo does-not-exist?
zsh: no matches found: does-not-exist?
You can make zsh
suppress the error and print the pattern:
$ setopt nonomatch
$ echo does-not-exist?
does-not-exist?
You can make bash
behave like zsh
with nomatch
option set, by turning on failglob
:
$ shopt -s failglob
$ echo does-not-exist?
bash: no match: does-not-exist?
More general, you can disable shell filename generation:
$ set -f
$ : "The command"
$ set +f
(or set -o noglob
, set +o noglob
)
or using one of shell quoting methods to make the shell treats ?
and other pattern matching special characters literally.
zsh
also provide the noglob
builtin, which disable filename generation in any words for the following simple command:
$ noglob echo *
*
Best Answer
What happens is that
bash
replaces the tabs with spaces. You can avoid this problem by saying"$line"
instead, or by explicitly cutting on spaces.