-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
cmd/shfmt: skip zsh scripts when walking directories #535
Comments
Thanks for the issue - I agree this is a bit weird. Right now, if a file has the right extension (in this case, |
@texastoland see #120. It would be a lot of work to add support, and a lot of work afterwards to maintain (which would likely fall on just me). So the decision thus far is not to support it. If someone wants to provide an implementation, and possibly maintain it in the long run, I'm all ears. But noone has stepped up so far :) |
I've hit a bit of a roadblock here, and that's because of the If we make If we make The best alternative here is probably to support all common POSIX shell variants which use |
I think you should keep including zsh files. In my opinion, the current, somewhat broken support for zsh, is better than no support at all. |
It's increasingly likely that we will support zsh in the future, given it being a default for Mac, so I think that's the best long-term solution. |
@mvdan A long time has gone by sinvce your last comment… Is |
@thomasmerz subscribe to #120 if you want to see the updates when there are any. |
While we eagerly await zsh support in shfmt, it would fix more projects near term, to temporarily skip file paths of zsh files ( As a workaround, I am using a custom sh family finding tool and telling it to skip zsh-related files, before passing them to shfmt: stank -exInterp zsh . |
grep -v node_modules |
xargs shfmt [any other shfmt options here] This is fragile (breaks on any file paths involving spaces). It requires grep, which may not necessarily be installed in all environments. It requires a separate process, which is wasteful. And it means having to manage a fairly long command in a build configuration file (Makefile, Rakefile, magefile.go, Shakefile.hs, vast.sh, CMakeLists.txt, rez.c/rez.cpp, etc.) And if any files get accidentally copied to the local tree via Ideally, shfmt would automatically exclude more files which is cannot handle, and learn to integrate into industry standard tooling like |
To prevent `shfmt` from discovering `zsh` files which aren't currently supported for formatting. This fixes mvdan#535 and the following test: > cmpenv stdout find.golden diff stdout find.golden --- stdout +++ find.golden @@ -16,6 +16,4 @@ modify/shebang-space modify/shebang-tabs modify/shebang-usr-sh -skip/ext.zsh -skip/shebang-zsh symlink/subdir/ext-shebang.sh FAIL: testdata/script/walk.txtar:10: stdout and find.golden differ It could be considered a breaking change to `shfmt` and `fileutil`. There's some discussion in that issue about whether it's beneficial to match `zsh` files because they can _sometimes_ be formatted if they don't contain any zsh-specific syntax, but without any way to explicitly exclude them from discovery it's more of a hindrance than help.
Hi, thanks for this tool! :)
I understand from #120 that zsh is not going to be supported, but the tool (tried with
3.1.0
) still wants to format them. I use shfmt in my CI builds to check if the scripts are correctly formatted, and I suppose that if zsh is not supported, it shouldn't try to format it, right?Example:
Output of
shfmt -d .
:script.sh:3:39: parameter expansion requires a literal
This makes my build fail, unless I exclude zsh scripts and call
shfmt -d
on each file instead. So there's a workaround, but since shfmt does not support zsh, it shouldn't attempt to format them.What do you think? Thanks!
The text was updated successfully, but these errors were encountered: