cd $Script_Dir
clear
read -p "Enter name of script to run shellcheck on. -> " n1
shellcheck "$n1"
In shellchk.sh line 10:
read -p "Enter name of script to run shellcheck on. -> " n1
^-- SC2162: read without -r will mangle backslashes.为什么要这么说?我绝不会在文件名中使用反斜杠。
如果我用
read -r "Enter name of script to run shellcheck on. -> " n1
/home/andy/bin/nshellchk.sh: line 11: read: `Enter name of script to run shellcheck on. -> ': not a valid identifier
: : openBinaryFile: does not exist (No such file or directory)发布于 2022-09-17 07:45:25
read是bash内建的。help read告诉
-r不允许反斜杠转义任何字符
shellcheck警告不要使用read而不使用-r,因为read不会像现在这样读取反斜杠。如果不需要启用反斜杠函数,请使用-r。shellcheck不知道是否要在文件名中使用反鞭子。
如果希望-p显示提示文本,则必须使用read。所以你可能想用
read -r -p "Enter name of script to run shellcheck on. -> " n1https://askubuntu.com/questions/1429809
复制相似问题