TransWikia.com

How do I syntax check a Zsh script?

Unix & Linux Asked by Akhil Jalagam on August 9, 2020

I can do it in bash using bash -n script.sh command.
is this possible in zsh?

One Answer

Is it's the same -n/-o noexec as in POSIX shells, that causes the code to be read and parsed but not executed.

See info zsh noexec for details.

Beware it flags shell syntax errors, but not necessarily things like wildcard/qualifier/expansion flag syntax errors.

Also note that some options affect the syntax of the shell. So if you have some set -o those-options, since it will not be executed, zsh -n will carry on trying to interpret the syntax as if it hadn't been enabled.

Answered by Stéphane Chazelas on August 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP