zsh-workers
 help / color / mirror / code / Atom feed
* What a Zsh linter should do?
@ 2018-11-23 15:17 Sebastian Gniazdowski
  2018-11-23 19:19 ` dana
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2018-11-23 15:17 UTC (permalink / raw)
  To: Zsh hackers list

Hello!
I'm wondering about functionality of a possible Zsh linter. Let's say
that the general idea is similar to shellcheck.

I think that the standard functionality – telling user to write a
nicer code – isn't a good one for Zshell. For example: telling user to
use `if' instead of [[ ... ]] && { ... ((1)); } || { ... } – I think
this is wrong for Zshell, where the "density" of code increases as
skills increase, and the programmer is e.g. being able to write a
"dense" one-liner utilizing :-, :+, :#, (M) instead of multi-line
if/else or even [[ ]] && { } || { }.

So what could a Zsh linter actually do?

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: What a Zsh linter should do?
  2018-11-23 15:17 What a Zsh linter should do? Sebastian Gniazdowski
@ 2018-11-23 19:19 ` dana
  0 siblings, 0 replies; 2+ messages in thread
From: dana @ 2018-11-23 19:19 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On 23 Nov 2018, at 09:17, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
>I think that the standard functionality – telling user to write a
>nicer code – isn't a good one for Zshell. For example: telling user to
>use `if' instead of [[ ... ]] && { ... ((1)); } || { ... } – I think
>this is wrong for Zshell, where the "density" of code increases as
>skills increase

ShellCheck doesn't tell you to avoid the `foo && bar || baz` construction
because `if` is less dense, it's because many people mistakenly assume that it's
equivalent to `if foo; then bar; else baz; fi`, and their script fails in
unexpected ways as a result. The linter obv has no way of knowing what the
person who wrote the code actually meant, all it can do is warn them that it's
dangerous. Just like `if ( foo = bar ) { ... }` in C-like languages

Anyway, i can't think of any ShellCheck warnings that aren't suitable for zsh,
aside from the ones that are obviously functionally/syntactically irrelevant
(must use [@] with arrays, can't use `{1..$n}`, must quote parameter expansions
to prevent globbing, &c.). All of the other stuff about escaping, and quoting,
and not trying to parse ls, and not doing `echo $(cmd)`, and so on, is just as
valid when writing zsh scripts

dana


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-23 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-23 15:17 What a Zsh linter should do? Sebastian Gniazdowski
2018-11-23 19:19 ` dana

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).