shunit2 icon indicating copy to clipboard operation
shunit2 copied to clipboard

macOS zsh: sourcing ./shunit2 throws an error: _shunit_fatal:1: command not found: echo -e

Open alexbigkid opened this issue 4 years ago • 3 comments

Hi Kate,

Just discovered your GIT repo. Great work! Until now I always tested shell scripts manually. Trying to write few tests with your unit test framework.

Having a problem to run it on zsh shell though. I traced it down to ./shunit2 line 40-44. when sourcing the the lib with ". ./shunit2" it throws an error: _shunit_fatal:1: command not found: echo -e

I am running on macOS BigSur 11.5.2, zsh version 5.8. Here are the details: $ uname -mprsv Darwin 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64 i386

shell name: zsh shell version: 5.8

--- Executing the 'sbxCommon' test suite --- _shunit_fatal:1: command not found: echo -e

the bash and sh is running fine though

alexbigkid avatar Sep 03 '21 04:09 alexbigkid

Can you provide some sample code that demonstrates the problem? Feel free to only share enough to demonstrate the issue.

Also, shUnit2 is tested using 'set -u' and 'set -e'. Are there other options set in your environment?

kward avatar Oct 23 '21 10:10 kward

To note, this is what I get when running a quick test on my local machine running macOS Monterey 12.0.1.

[kward@kward-macpro13 2021-10-23T18:08:44 %1]~/var/wa/github.com/kward/shunit2
$ uname -a
Darwin kward-macpro13.ka.corp.forestent.com 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
[kward@kward-macpro13 2021-10-23T18:08:47 %1]~/var/wa/github.com/kward/shunit2
$ zsh
kward@kward-macpro13 shunit2 % ./shunit2

Ran 0 tests.

OK
kward@kward-macpro13 shunit2 % zsh --version
zsh 5.8 (x86_64-apple-darwin21.0)

Obviously this isn't testing your setup…

kward avatar Oct 23 '21 16:10 kward

Actually, this is the issue that can be fixed by setting the shwordsplit option for zsh, see here.

JussiPekonen avatar Aug 19 '22 12:08 JussiPekonen