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.