做娱乐网站被坑,沈阳网站建设开发维护,网站建设方案书0,贵阳花溪区安装工具 通过linux yum源下载#xff0c;可能因为yum源的问题找不到软件包#xff0c;或者下载的软件包版本太旧。 ShellCheck的源代码托管在GitHub上(推荐下载方式)#xff1a;
GitHub - koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts 对下…安装工具 通过linux yum源下载可能因为yum源的问题找不到软件包或者下载的软件包版本太旧。 ShellCheck的源代码托管在GitHub上(推荐下载方式)
GitHub - koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts 对下载的可执行程序压缩包进行解压将shellcheck可执行命令加入环境变量拷贝至/bin/下以方便在任何位置都可以通过tab键补齐shellcheck并使用。
使用shellcheck
#!/bin/bash # 设置编译器和编译选项
COMPILERarm-linux-gnueabihf-g #CPP编译器
COMPILE_FLAGS_JSONCPP-L /usr/local/lib /usr/local/lib/libjsoncpp.a #链接 jsoncp库
COMPILE_FLAGS_CGICC-I /usr/local/cgicc-3.2.20/include -L /usr/local/cgicc-3.2.20/lib -lcgicc #链接 cgicc库
COMPILE_FLAGS_SQLITE3-I /usr/local/sqlite3/include/ -L /usr/local/sqlite3/lib/ -lsqlite3 #链接 sqlite3库
COMPILE_FLAGS_OPENSSL-I /usr/local/arm-openssl-3.0/include/ -L /usr/local/arm-openssl-3.0/lib64/ -lcrypto #链接 crypto库UPHOLD_TOOLSuphold_tools
cd $UPHOLD_TOOLS
$COMPILER -o $UPHOLD_TOOLS.cgi $UPHOLD_TOOLS.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPP $COMPILE_FLAGS_OPENSSL
if [ $? -ne 0 ]; thenecho Error compiling $UPHOLD_TOOLSexit 1
fi
SYSTEM_REBOOTsystem_reboot
$COMPILER -o $SYSTEM_REBOOT.cgi $SYSTEM_REBOOT.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPP
if [ $? -ne 0 ]; thenecho Error compiling $SYSTEM_REBOOTexit 1
fi
cd ..
#拷贝.cgi和.sh到radio-gateway中
find $UPHOLD_TOOLS -type f \( -name *.cgi -o -name *.sh \) -exec cp {} ../radio-gateway/cgi-bin/$UPHOLD_TOOLS \;
if [ $? -ne 0 ]; then echo Error copy $UPHOLD_TOOLSexit 1
fi#拷贝web源代码到radio-gateway中
cp -r ../web ../radio-gateway/
rm -rf ../radio-gateway/web/index.html
cp ../web/index.html ../radio-gateway/echo Compilation and copy successful.
优化建议
[rootlocaldomain home]# shellcheck compile.sh In compile.sh line 7:
COMPILE_FLAGS_SQLITE3-I /usr/local/sqlite3/include/ -L /usr/local/sqlite3/lib/ -lsqlite3 #链接 sqlite3库
^-------------------^ SC2034 (warning): COMPILE_FLAGS_SQLITE3 appears unused. Verify use (or export if used externally).In compile.sh line 11:
cd $UPHOLD_TOOLS
^--------------^ SC2164 (warning): Use cd ... || exit or cd ... || return in case cd fails.Did you mean:
cd $UPHOLD_TOOLS || exitIn compile.sh line 12:
$COMPILER -o $UPHOLD_TOOLS.cgi $UPHOLD_TOOLS.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPP $COMPILE_FLAGS_OPENSSL^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.^--------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.^--------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean:
$COMPILER -o $UPHOLD_TOOLS.cgi $UPHOLD_TOOLS.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPP $COMPILE_FLAGS_OPENSSLIn compile.sh line 13:
if [ $? -ne 0 ]; then^-- SC2181 (style): Check exit code directly with e.g. if ! mycmd;, not indirectly with $?.In compile.sh line 18:
$COMPILER -o $SYSTEM_REBOOT.cgi $SYSTEM_REBOOT.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPP^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.^--------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean:
$COMPILER -o $SYSTEM_REBOOT.cgi $SYSTEM_REBOOT.cpp $COMPILE_FLAGS_CGICC $COMPILE_FLAGS_JSONCPPIn compile.sh line 19:
if [ $? -ne 0 ]; then^-- SC2181 (style): Check exit code directly with e.g. if ! mycmd;, not indirectly with $?.In compile.sh line 23:
cd ..
^---^ SC2103 (info): Use a ( subshell ) to avoid having to cd back.In compile.sh line 26:
if [ $? -ne 0 ]; then ^-- SC2181 (style): Check exit code directly with e.g. if ! mycmd;, not indirectly with $?.For more information:https://www.shellcheck.net/wiki/SC2034 -- COMPILE_FLAGS_SQLITE3 appears unu...https://www.shellcheck.net/wiki/SC2164 -- Use cd ... || exit or cd ... |...https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
[rootlocaldomain home]#