测试POSIX Shell的合规性?

编程入门 行业动态 更新时间:2024-10-25 22:35:47
本文介绍了测试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的合规性?

本文发布于:2023-08-01 16:44:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269947.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   POSIX   Shell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!