从bash脚本询问时,我想重写配置文件。这是我的代码。
function quality {
echo $1 > ~/.livestreamerrc
echo ".livestreamer was modified!"
}
best="stream-types=hls
hls-segment-threads=4
default-stream=best
player=vlc --cache 5000"
read -p "Set quality: " INPUT
if [[ "$INPUT" == "!best" ]]; then
quality $best
fi
这段代码可以执行以下.livestreamer
操作。
$cat ~/.livestreamerrc
stream-types=hls
为什么?
更改为
quality "$best" # double quotes to avoid word splitting
然后
echo "$1" > ~/.livestreamerrc
注意:值得检查[shellcheck]文档。另外,完全大写的变量(如)INPUT
也为系统保留。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句