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 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!

Related Questions

All processes running on the same core

1  Asked on December 24, 2020 by roofkiller


capturing yum update transaction to replicate on another machine

0  Asked on December 23, 2020 by dan-schneider


Add Support CRAM-MD5 or DIGEST-MD5 to SMTP server

0  Asked on December 22, 2020 by alpav99


Linux delete lines from ini-file where key has no value

1  Asked on December 21, 2020 by sunwave121


What caused traffic on port 631?

0  Asked on December 21, 2020 by u20200411


Bind/Unbind Linux Module Automatically

1  Asked on December 20, 2020 by vladius


ls everything that is _not_ a symlink

1  Asked on December 20, 2020


Netgear39 Removal

0  Asked on December 20, 2020 by danny-bender


Join two csv files by matching columns, join command

1  Asked on December 20, 2020 by cdxun


Arithmetic on values with memory size units

4  Asked on December 20, 2020 by malan


case while option not showing last argument in shell script

1  Asked on December 19, 2020 by user2358844


Debian update to Buster, iptables throwing an error in

1  Asked on December 19, 2020 by jademalo


Logitech Marble Mouse – Linux Scroll Modifier Setup

3  Asked on December 18, 2020 by peter-l


ZFS setup, adding drives on the go

0  Asked on December 18, 2020 by timyorgut


Linux Font “Lato” is not available to the JVM

0  Asked on December 18, 2020 by valene


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir