Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh option for checking if a file is a shell script



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.



Messages sorted by: Reverse Date, Date, Thread, Author