A note on testing shell scripts

2026-10-29来源 dev.to TestingEnglish

I write a lot of small bash scripts and almost never test them. This week I added two tests with bats and found a quoting bug that would have eaten a filename with spaces.

The tests aren't clever: make a temp dir, run the script, assert output. Ten lines.

I won't pretend this makes bash pleasant, but a couple of tests turn it from 'hope it works' into 'probably works'.

原文:https://www.a8q9.cn/en/article/a-note-on-testing-shell-scripts-067367.html

相关文章