Just as the title, I am starting using ShellCheck as a static tool to analyze and help to imrove the shell script, and I am asked a question about the standard this tool referring to to carry out the scan work and the output that based on.
I googled it and expected to see the standard is from Google, Redhat, or Linux community, or even Mirosoft(I know this would be funny if it's true), or anyt tech giant, but I haven't found any clues, so could any one share with me these information?
就像标题一样,我开始使用ShellCheck作为一个静态工具来分析和帮助改进shell脚本,有人问我一个问题,这个工具指的是什么标准来进行扫描工作,以及基于什么标准的输出。我在谷歌上搜索了一下,希望看到这个标准来自谷歌、Redhat或Linux社区,甚至Mirosoft(我知道如果这是真的,那会很有趣),或者任何科技巨头,但我还没有找到任何线索,所以有人能和我分享这些信息吗?
更多回答
Since ShellCheck can check scripts in a variety of language (zsh for instance), most of them not being formally "standardized", it does not make much sense to ask for a standard. I would expect that for sh scripts, the shell defined in POSIX.1-2017 is used as a reference.
由于ShellCheck可以检查各种语言(例如zsh)的脚本,其中大多数都不是正式的“标准化”,因此要求标准没有多大意义。我希望对于sh脚本,使用POSIX.1-2017中定义的shell作为参考。
@user1934428 Thank you first for your comment. I agree with you on the point that script language varies, but just like what you've mentioned in the example, 'zsh' is a script language, and it has its own syntax, thus the syntax could be a standard. Let's take your point as a new start and break the original question down, are there standards for each of the script language supported by ShellCheck, e.g. zsh, bash?
@user1934428首先感谢您的评论。我同意你的观点,脚本语言各不相同,但就像你在例子中提到的那样,“zsh”是一种脚本语言,它有自己的语法,因此语法可能是一种标准。让我们从新的角度来看待你的观点,并分解最初的问题,ShellCheck支持的每种脚本语言都有标准吗,例如zsh、bash?
Depends on which zsh version you are refering to. Over the lifetime, several features and language constructs have been added. Same with bash. Early bash did not have associative arrays for instance. Especially with zsh, I was bitten several times when porting my scripts to a newer version, and my old scripts did not run anymore ....
取决于您所引用的zsh版本。在使用寿命中,添加了一些功能和语言结构。bash也是如此。例如,早期的bash没有关联数组。尤其是在使用zsh时,我在将脚本移植到新版本时被咬了好几次,而且我的旧脚本不再运行。。。。
@user1934428 Haha, I can understand the feeling of that one development only works for one version. That's bad indeed. Thank you for your input.
@user1934428哈哈,我能理解一个开发只适用于一个版本的感觉。这确实很糟糕。感谢您的意见。
If you are talking about messages like "egrep is non-standard" then it's referring to POSIX.
如果您谈论的是像“egrp是非标准的”这样的消息,那么它指的是POSIX。
There's no standard. It's based on its authors' opinions which are documented on its website.
没有标准。这是基于作者的意见,这些意见记录在其网站上。
更多回答
Thank you for the first answer. If it all has based the author's/contributor's opintions, how could we say the author's/contributor's opinions are all correct? Maybe it sounds unnecessary that the endorsement is needed, but I think this could be more convincing.
谢谢你的第一个回答。如果这一切都是基于作者/撰稿人的意见,我们怎么能说作者/投稿人的意见都是正确的呢?也许需要背书听起来没有必要,但我认为这可能更有说服力。
They aren't "correct", they are opinions. (Their documentation makes justifications for them.)
它们不是“正确的”,它们是观点。(他们的文件为他们辩护。)
Thank you for the further comment. I found Google and Gitlab is using it to check shell, this is convincing enough.
感谢您的进一步评论。我发现谷歌和Gitlab正在用它来检查shell,这已经足够令人信服了。
我是一名优秀的程序员,十分优秀!