From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29216 invoked by alias); 12 Aug 2010 16:12:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15276 Received: (qmail 8932 invoked from network); 12 Aug 2010 16:12:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <100812091209.ZM20191@torch.brasslantern.com> Date: Thu, 12 Aug 2010 09:12:09 -0700 In-reply-to: Comments: In reply to Guillaume Brunerie "Zsh option for checking if a file is a shell script" (Aug 12, 12:23pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Zsh option for checking if a file is a shell script MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 12, 12:23pm, Guillaume Brunerie wrote: } } Is there some option (for example --check-syntax) such that } $ zsh --check-syntax /path/to/a/shell/script } doesn't do anything except that the return code would be 0 } if /path/to/a/shell/script is indeed a shell script, and non zero otherwise? $ zsh -n /path/to/some/file or equivalently but more obviously $ zsh -o no_exec /path/to/some/file will parse but not execute the file, and exit with failure if there is a parse error. However, just because a file doesn't cause a parse error is not a guarantee that it is a shell script, and parsing a very big file is potentially expensive.