Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh option for checking if a file is a shell script
- X-seq: zsh-users 15284
- From: Guillaume Brunerie <guillaume.brunerie@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Zsh option for checking if a file is a shell script
- Date: Mon, 16 Aug 2010 22:52:15 +0200
- Cc: zsh-users@xxxxxxx
- 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=
- In-reply-to: <100812091209.ZM20191@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTinuOXQNHbiPcriXRcHfs_c3rX=QCF2kwZu9DOtq@xxxxxxxxxxxxxx> <100812091209.ZM20191@xxxxxxxxxxxxxxxxxxxxxx>
2010/8/12 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author