Bash variable expansion
I'm trying to do some variable expansion in bash but somehow the result is truncated/rotated. Here's a sample my code:
x="no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0"
tts="{$x}"
echo $tts
This prints: }no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0
I expected: {no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0}
If I change tts to tts=abc{开发者_开发问答$x}qwe
the output is }qweno-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0
I tried escaping the braces and removing the quotes, still doesn't work. I know there's something that has to be escaped but I can't figure out what.
bash --version
output: GNU bash, version 3.2.48(21)-release (i686-pc-cygwin)
You're getting your $x
from somewhere else, and it has a \r
at the end. Try:
tts="{${x/$'\r'/}}"
精彩评论