From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5928 invoked by alias); 16 Aug 2010 20:52:40 -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: 15284 Received: (qmail 4066 invoked from network); 16 Aug 2010 20:52:37 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.161.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=rfa8lzeJoQnefUFl9tNxlonpA3LgKmpQiGpEG89Byo8=; b=ZcFuSeIEJT+XEH6GawiApNFQCj9KnXvN2zyt0c/EY4dWEe8e8uI2ad/qiAhvwI8vT6 FS2EluwdPQ66aIpdv/apzRCfzuj4V4VCI6Qt+UyeY2ZBcQCgdMjYn4ssRkQqYOxj6EaL MJJ7FfazPaKAD+VqqcaoH77rJUw4zVwkuXYcs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=ljKI4E2VI5jAVqpK/k6QbKTF6ryRskwS6BIN8INkDRd0OPb2yaUS/ILcqAFY725XF2 nDf+MNHrQe5HxvfPcWS8FvSdGDXsheEm/aMS9psOdMCc7yjvkFmdg9g4hy4v/Usv9COM SPe9jrhKsXQmlCdmwmdax0HhxUHeJEkJG2ok4= MIME-Version: 1.0 In-Reply-To: <100812091209.ZM20191@torch.brasslantern.com> References: <100812091209.ZM20191@torch.brasslantern.com> From: Guillaume Brunerie Date: Mon, 16 Aug 2010 22:52:15 +0200 Message-ID: Subject: Re: Zsh option for checking if a file is a shell script To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=0014853d0106d26d8b048df7020a --0014853d0106d26d8b048df7020a Content-Type: text/plain; charset=UTF-8 2010/8/12 Bart Schaefer > 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. Thank you :-) > 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. > I want that because I have aliased cat to use 'source-highlight' when given only one argument (in order to have syntax highlighting in the shell) and this doesn't work for shell scripts without extension nor shebang (like most system scripts in /etc). But it seems indeed that many files are syntactically correct but aren't at all shell scripts (like /etc/inittab). If someone knows a better solution, please let me know. --0014853d0106d26d8b048df7020a--