测试POSIX Shell的合规性? [英] Test for POSIX shell compliance?

查看:76
本文介绍了测试POSIX Shell的合规性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何测试Shell脚本以验证它是否符合POSIX?我有大量的脚本为各种版本的Bash和可能的其他Shell编写.我希望能够确定哪些完全符合POSIX,哪些不符合POSIX.理想情况下,我想找到类似lint的东西,但要用于shell脚本.

How can I test a shell script to verify that it is POSIX compliant? I have a large set of scripts written for various versions of Bash and possibly other shells. I'd like to be able to determine which are fully POSIX compliant and which are not. Ideally, I'd like to find something like lint but for shell scripts.

推荐答案

无法静态验证脚本是否符合POSIX,因为差异不限于语法更改,而某些差异只是更改某些命令的行为方式.此链接描述了bash和POSIX之间的区别标准.

It's not possible to statically verify if a script is POSIX compliant because the differences are not restricted to syntax changes and some differences simply changes the way some commands behave. This link describes the differences between bash and POSIX standard.

但是,您可以使用bash --posix ./your_script.sh或在其中使用set -o posix来显式检查运行的脚本.

However, you can explicitly check your scripts running then with bash --posix ./your_script.sh or using set -o posix inside them.

这篇关于测试POSIX Shell的合规性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆