当前位置: 首页 > news >正文

网站怎么开发红桥网站建设公司

网站怎么开发,红桥网站建设公司,石家庄网站建设就找,贵州省职业技能学历双提升工程大家好,今天分享一款开源工具--shellcheck。 shellcheck 简介 今天发现的一款神器,如果你日常会接触到shell脚本,或者说自己需要写一些shell脚本,那么强烈建议你用下这个工具。 shellcheck一个静态的shell脚本分析工具&#xf…

大家好,今天分享一款开源工具--shellcheck。

shellcheck 简介

今天发现的一款神器,如果你日常会接触到shell脚本,或者说自己需要写一些shell脚本,那么强烈建议你用下这个工具。

shellcheck一个静态的shell脚本分析工具,可以判断脚本哪里有异常,哪里可以优化,并且会给出对应的解决办法。

一个简单的示例:

图片

这款工具不仅适用于初学者,对于中高级使用者帮助更大。

安装

github可以访问的直接到如下链接去下载就可以,目前支持多个终端,也有web可访问

https://github.com/koalaman/shellcheck

web访问地址:https://www.shellcheck.net/

使用方式:

shell脚本中的一些常见错误

  1. 常见错误引用

echo $1                           # Unquoted variables
find . -name *.ogg                # Unquoted find/grep patterns
rm "~/my file.txt"                # Quoted tilde expansion
v='--verbose="true"'; cmd $v      # Literal quotes in variables
for f in "*.ogg"                  # Incorrectly quoted 'for' loops
touch $@                          # Unquoted $@
echo 'Don't forget to restart!'   # Singlequote closed by apostrophe
echo 'Don\'t try this at home'    # Attempting to escape ' in ''
echo 'Path is $PATH'              # Variables in single quotes
trap "echo Took ${SECONDS}s" 0    # Prematurely expanded trap
unset var[i]                      # Array index treated as glob
  1. 常见错误条件语句

[[ n != 0 ]]                      # Constant test expressions
[[ -e *.mpg ]]                    # Existence checks of globs
[[ $foo==0 ]]                     # Always true due to missing spaces
[[ -n "$foo " ]]                  # Always true due to literals
[[ $foo =~ "fo+" ]]               # Quoted regex in =~
[ foo =~ re ]                     # Unsupported [ ] operators
[ $1 -eq "shellcheck" ]           # Numerical comparison of strings
[ $n && $m ]                      # && in [ .. ]
[ grep -q foo file ]              # Command without $(..)
[[ "$$file" == *.jpg ]]           # Comparisons that can't succeed
(( 1 -lt 2 ))                     # Using test operators in ((..))
[ x ] & [ y ] | [ z ]             # Accidental backgrounding and piping
  1. 误用的命令

grep '*foo*' file                 # Globs in regex contexts
find . -exec foo {} && bar {} \;  # Prematurely terminated find -exec
sudo echo 'Var=42' > /etc/profile # Redirecting sudo
time --format=%s sleep 10         # Passing time(1) flags to time builtin
while read h; do ssh "$h" uptime  # Commands eating while loop input
alias archive='mv $1 /backup'     # Defining aliases with arguments
tr -cd '[a-zA-Z0-9]'              # [] around ranges in tr
exec foo; echo "Done!"            # Misused 'exec'
find -name \*.bak -o -name \*~ -delete  # Implicit precedence in find
# find . -exec foo > bar \;       # Redirections in find
f() { whoami; }; sudo f           # External use of internal functions
  1. 初学者常见错误

var = 42                          # Spaces around = in assignments
$foo=42                           # $ in assignments
for $var in *; do ...             # $ in for loop variables
var$n="Hello"                     # Wrong indirect assignment
echo ${var$n}                     # Wrong indirect reference
var=(1, 2, 3)                     # Comma separated arrays
array=( [index] = value )         # Incorrect index initialization
echo $var[14]                     # Missing {} in array references
echo "Argument 10 is $10"         # Positional parameter misreference
if $(myfunction); then ..; fi     # Wrapping commands in $()
else if othercondition; then ..   # Using 'else if'
f; f() { echo "hello world; }     # Using function before definition
[ false ]                         # 'false' being true
if ( -f file )                    # Using (..) instead of test

资源获取:

(1)自己从 github 仓库拉取。

http://www.laogonggong.com/news/100117.html

相关文章:

  • 心悦会员免做卡网站旅游在哪个网站做攻略
  • hao123网站源码制作2015最新仿网站建设带后台带微商城
  • 本地的上海网站建设做网站难度大吗
  • 哪里可以做外贸网站百度一下浏览器
  • 北理工网站开发与运用网络推广站
  • 网站导航网站怎么做php与网站开发
  • 做服装设计看哪些网站h5网页制作代码
  • 门户网站的建设目的沈阳求做商城 网站
  • 绍兴网站建设哪家专业服务器上 网站
  • 抓取网站访问量营销型网站需要备案吗
  • 湖北高端网站建设建站平台备案
  • 住房和城乡建设部网站注册网站开发过程中遇到的问题
  • 东莞网站建设公司企业国内最近新闻
  • 河北网站制作公司哪家好网站开发需要哪些职位
  • 手机网站如何做营销php做网站用什么软件
  • 福州市工程建设监督站网站建设网站方法有哪些
  • 宁远县建设局网站中信建设有限责任公司洪波
  • 网站建设基础筹备emlog做企业网站
  • 什么网站可以做市场分析呢网站开发心得体会
  • 肃州区建设局网站wordpress 入侵视频
  • 重庆平台网站建设工企业软件定制开发报价
  • icp网站信息做搜索的网站有哪些
  • wordpress 导航站主题兰州微网站
  • 广州网站建设网站制作公司怎么做卡蜜网站
  • 房城乡建设部门户网站整站系统
  • wordpress 菜单浮动广东做seo的公司
  • 成都建设局网站旅游自媒体网站怎么做
  • 咸阳网站建设价格网页制作大宝库官网
  • 手机视频网站开发教程python网站开发实例教程
  • 哪个网站可以做设计比赛网站搜索排名优化价格