Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

zsh is not officially supported, but you can force shellcheck to check zsh regardless via `--shell=bash`.

This makes shellcheck treat the file as bash script, so there are some false positives for zsh-specific syntax, but 99% of the rules work pretty much the same.



Certainly for my own scripts it's a lot less than "99%". It won't even run on most of them as it will just exit on some fatal error:

Special variables like $argv and $status.

Most array things (e.g. ${(o)arr} for an ordered array)

(( .. )) conditionals

"short loops" without "do".

repeat loops.

You could rewrite these things, but what errors remain where shellcheck is helpful in zsh?


well, for me it's 99%. But true, I don't use short loops, and I also don't use array a lot (when I feel the needs to use arrays, I switch to a different language anyway).

"what errors remain" is hard for me to say – I get a wide variety of helpful errors, regularly.


Even in simple scripts I found arrays to be very helpful once I let go of the "POSIX sh mindset" and was used to it. The way word-splitting and $IFS works is basically like an "implicit array", as is $@, $1, etc. (actually in zsh $@ is an array: $1, $@[1], $*[1], and $argv[1] are all the same), so everyone already uses arrays.

It replaces a lot of uses of cut and "awk '{print $2}" for starters.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: