diff mbox series

[1/2] test: fix build for zsh

Message ID 20230401015632.103581-2-felipe.contreras@gmail.com (mailing list archive)
State New, archived
Headers show
Series test: add support for zsh and zsh completion | expand

Commit Message

Felipe Contreras April 1, 2023, 1:56 a.m. UTC
zsh has the ability to emulate Bourne shell, which is closer to what our
testing suite expect.

Using the POSIX_ARGZERO option makes $0 behave as POSIX seems to define:
show the name of the command launched, as opposed to the zsh default:
the path of the script.

This enables many tests, but not all.

We can run the tests with `zsh --emulate sh` which has more more
compatibility, but doing `emulate sh` inside the script allows us to
just use `zsh`, although it's not as compatible.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/test-lib.sh | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Eric Sunshine April 1, 2023, 5:33 a.m. UTC | #1
On Fri, Mar 31, 2023 at 10:16 PM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> zsh has the ability to emulate Bourne shell, which is closer to what our
> testing suite expect.

s/expect/expects/

> Using the POSIX_ARGZERO option makes $0 behave as POSIX seems to define:
> show the name of the command launched, as opposed to the zsh default:
> the path of the script.
>
> This enables many tests, but not all.
>
> We can run the tests with `zsh --emulate sh` which has more more
> compatibility, but doing `emulate sh` inside the script allows us to
> just use `zsh`, although it's not as compatible.

s/more more/more/

> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
diff mbox series

Patch

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62136caee5..d5a9168484 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -15,6 +15,11 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .
 
+if test -n "${ZSH_VERSION-}"
+then
+	emulate sh -o POSIX_ARGZERO
+fi
+
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in 'trash directory' subdirectory.
 if test -z "$TEST_DIRECTORY"