-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support zsh #809
Comments
I'd love it if |
As someone with quite a few big ZSH projects out in the wild, I'd definitely be interested in seeing this happen. I'd be very happy to contribute myself if someone could let me know what would be required to get it implemented. |
@molovo: first you have to ask yourself if the features of 'zsh' are a subset of other shells or if zsh has own features. look into the source for 'first citizen shells' and the handling of 'dash' and 'bash' and you will get a feeling, what is needed... |
This would require:
Ksh shares basically all its syntax with Bash, which is why it's still supported even though almost no one uses it. Zsh required a lot more work for a similarly small number of users, which is why I unfortunately wasn't able to keep it up. |
If zsh is ever supported, it should recognize |
@koalaman I understand that |
@kgizdov on the other hand a PR with the start is pretty much the same. I assume that if you gather some people to do the work either they are welcome to the project or they will fork it. |
I looked into this briefly a couple weeks ago. After I read through most of Parser.hs it was apparent that koalaman's step 1 would require deep knowledge of zsh syntax and bash syntax and a decent understanding of Haskell. That made me wonder if zsh's parser (it's in C) could be used directly or modified slightly to emit an AST that could be interfaced to some high-level language constructs in Haskell or some other language. The wrapping is a bit involved, but is less work than reimplementing the parser. I'm curious, has anyone on this thread worked with the zsh source? |
@paulmelnikow I haven't worked with the source, but I have considered building an AST or something similiar (not for this purpose, but to support a coverage driver for zunit). I wonder if something could be built to tackle both issues at once? |
@molovo Interesting idea! |
Maybe the wiki could recommend a shellcheck alternative for zsh users? Because all Google searches based on variants of |
Unfortunately, there is no such equivalent. If anyone could make it happen, that'd be @molovo. You may want to take a look at fish shell, which is better documented, more user-friendly, and developed on github. |
I would like a support for Zsh but well Bash is still pre-installed in all major distro. I code in Bash using Zsh...haha |
The github issue is the following: koalaman/shellcheck#809 Maybe an alternative linter could be used...
I guess one could still use shellcheck for bash-ish zsh files? To be more specific, I have quite a few config files related to my But being completely honest, I'm way more familiar with bash than with zsh, so sometimes when shellcheck is showing a warning, I'm not 100% sure if it applies to zsh as well. |
I see Zsh thing happening if:
I write this because I'm 3-years active Zsh (upstream) and Zsh-script-projects developer, and the above scenario covers my actual expectations to have a well organized environment/setup for working on a project. BTW., Zsh can parse its code itself with a |
There is so much commonality between {ba,z}sh that there would need to be a lot of importing upstream commits into the new project... @psprint What do you see as the advantages of a forked project? Would it make sense to:
(I'm assuming one syntax can import/inherit from another syntax here - please correct me if I've misunderstood) |
I think that without fork programmers will have to be real experts in Bash and Zsh. I learn Zsh for 3 years and sometimes there's still something that's new to me. If I imagine that I now would have to reach the same level in Bash but not through play & experiment like with Zsh, but with studying documentation, then I feel like running away from contributing. My experience also tells me that structural programming doesn't match situation, where every action that a program has to make is also a result of condition like "Bash or Zsh". If I imagine codebase that's doing constant "Bash or Zsh" checking, I see something really severe, a mess. This mess can be controlled but this doesn't match Open Source programmers, IMO. Even well paid corpo programmers could fail and consciously doom project's codebase if someone would require of them that level of self control and care for details. Nobody would be able to prove them that they're making a crime for their comfort. Forked project can just accumulate perfection in following Zsh syntax, it's a much simpler situation and it matches Open Source way of doing things. |
I believe that the answer may depend on whether whether one If it's possible, then perhaps something like this is possible:
This would hopefully avoid much of the shell version checking you describe. I wonder how it is currently done for @koalaman could you comment? |
Wouldn't the simplest approach be to create a zsh branch or in the initial logic choose which parser to use based on the bang line |
@HaleTom Ok the idea seems reasonable, it opens a way to do programming not whole-picture-grasping, which is pretty much the thing that I opt for. I think at this point, what's needed, is the Spellcheck authors to tell us how much the code is done in direct-structural way vs. indirect-with-high-degree-of-freedom way. I mean, you wrote about kind of syntax-"backends" that can be moved level-up or level-down between general-shell and specific-{bash,zsh} levels, to gradually separate things, but in reality I suspect this will have to be coded first, and I wonder how much parsing-knowledge or parsing-certainty/comfort would it require to actually approach this task. |
I appreciate your assumptions that ShellCheck is an enterprise level project with smart abstractions and a clever design, but you're really overestimating both it and me. Apart from being written in Haskell, ShellCheck is very simple and straight forward. It essentially just has one parser and one set of checks that are applied to the result. The parser handles all syntax for all shells the same way. If you use a Bash specific feature in Dash, such as There's no reason why you couldn't additionally recognize Zsh As for the checks, they don't have groups or stages. The only structure imposed is optional, and is purely for convenience and efficiency (like registering to handle a command name instead of having to iterate the AST to look for them). If a check is specific to a different shell, it'll just check and do an early return. I doubt any of that would be a concern though. 95%+ of checks that apply to Bash also apply to Zsh ( |
I see, from that point of view it looks easy. With the possible problems anticipated by me, I was thinking about things that are more subtle than an additional syntax. Like for example word-splitting being the default in bash, Zsh whole array referencing with |
@koalaman; Can it be said, that after implementing checks for a most easily-occurring mistakes, Shellcheck took a path of implementing checks for a more complex & rare, more specific, narrow, fine-grained mistakes? And that that's why the execution of a shell script has been implemented – to be able to dig into the states of the code and catch the fine-grained mistakes? |
Probably the biggest reason that this hasn't been implemented yet is that the project is written in Haskell, Lot's of folks don't know it since it doesn't follow in the train of standard C-based programming languages sigh 😞 |
So write one in in C and stop complaining. |
@TinCanTech The functional squad did not like that one. |
@HunterKohler .. is that like I think @koalaman has done more then enough already. See his reply above .. I think asking one man to port this entire project to a new language Perhaps Please, down-vote me again, if you do not understand what it takes to create |
You got them the first time (I bet) because your reply was unhelpful and rude without provocation.
If that’s what you took from @bl-ue’s comment, you’re extrapolating. They lamented that so few people know the language, they did not ask for a rewrite. Downvotes are meaningless on GitHub. Their only effect is increasing a number near an icon. Let’s move on and keep the conversation focused on adding (or not) ZSH support to Shellcheck. |
My apologies for any offence that I may have caused. One might equally lament any number of things (eg: JFK) .. but it serves no purpose.
Agreed. |
Hi, We are in 2022, a bit more than 5 years since this issue was originally created. I would like to see zsh support too. From all this thread I get is it not easy task but still wanted. zsh is the default in macOS. (The only reason I don't heavily use zsh in my scripts is because shellcheck does not support it. But I want to use zsh!) |
That is irrelevant. @koalaman owes us nothing and it’s their right to never work on this. That this issue is still open is a courtesy we’ve been given. This is a free project open for all to see. If you really want zsh support, the options are:
Anything different is at this point screaming into the void. If you want it to happen, make it happen. |
FWIW, I have started using (In case anyone is interested, it's a custom diagnostic source for Thanks to @koalaman for all his hard work on bash for shellcheck. It's saved many wasted hours debugging problems with shell scripts. |
Hi Andrew,
Yes, I plan for my "stank" shell script linter to do the same, running the
-n option based on a file's interpreter (or known dotfile association for
standard config scripts).
…On Thu, Feb 3, 2022, 7:24 AM Andrew Ferrier ***@***.***> wrote:
FWIW, I have started using zsh -n $FILENAME as a syntax checker
integration inside my editor. It does not do anything as close as to what
shellcheck does, but it will output the first error it finds in a pattern
similar to shellcheck. So it's better than nothing.
(In case anyone is interested, it's a custom diagnostic source for null-ls
in NeoVim - happy to share more details if anyone's interested).
Thanks to @koalaman <https://github.com/koalaman> for all his hard work
on bash for shellcheck. It's saved many wasted hours debugging problems
with shell scripts.
—
Reply to this email directly, view it on GitHub
<#809 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABJRBQR4SVU342QF6JPPLUZJ6Y5ANCNFSM4C2VX25Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@koalaman - I'm willing to put some significant time into this, but I definitely need some help on where to start in this to really contribute. If you're open to it, I think the recommendation here would be a good starting point. |
@pboushy I appreciate your enthusiasm, but to set expectations, this is an abnormally large and all-encompassing contribution that dwarfs all previous ones. I would expect it to take months of full time work. As you can tell from the speed of my replies, I'm don't have nearly the time I wish I did to help out either. If you'd still like to give it a whack, check out the DevGuide, and have a look at the quite readable Debug.hs that makes it easier to develop/test interactively. A good first step might be to try to implement the short forms of |
Should the tool suggest that, when it detects zsh shebang, there is an ongoing conversation on this topic? |
I've created a new linter for zsh called 🧽 zsh-sweep. It's at http://GitHub.com/psprint/zsh-sweep |
I used 'bash' for zsh files, since that's the closest and `shell=zsh` is not supported [1]. [1]: koalaman/shellcheck#809
Sadly, shellcheck does not support zsh [1], and it's not even possible to evaluate the script with zsh because it fails with: _arguments:comparguments:327: can only be called from completion function So the zsh script shall not be checked. [1] koalaman/shellcheck#809
Sadly, shellcheck does not support zsh [1], and it's not even possible to evaluate the script with zsh because it fails with: _arguments:comparguments:327: can only be called from completion function So the zsh script shall not be checked. [1] koalaman/shellcheck#809
Sadly, shellcheck does not support zsh [1], and it's not even possible to evaluate the script with zsh because it fails with: _arguments:comparguments:327: can only be called from completion function So the zsh script shall not be checked. [1] koalaman/shellcheck#809
Sadly, shellcheck does not support zsh [1], and it's not even possible to evaluate the script with zsh because it fails with: _arguments:comparguments:327: can only be called from completion function So the zsh script shall not be checked. [1] koalaman/shellcheck#809
So, I’ve noticed quite a while ago that zsh support had been removed. So, since christmas is a time for miracles, I thought I might check back on any recent developments. From searching the issue tracker I take it that nothing has changed in this regard. So I figured I might open this issue so that patient, interested parties can subscribe to it and get notified in case someone feels like stepping up.
That is of course if you do deem zsh support generally useful. Otherwise please feel free to close the issue.
Thanks for making shellcheck!
The text was updated successfully, but these errors were encountered: