TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Shfmt – format shell programs

115 pointsby typical182over 2 years ago

9 comments

VWWHFSfQover 2 years ago
The caveats are somewhat of a deal breaker unfortunately. It fails on perfectly valid syntax because they don't want to complicate the parser. But that makes the tool not very useful.
评论 #34755059 未加载
评论 #34756237 未加载
评论 #34755052 未加载
评论 #34754946 未加载
评论 #34760447 未加载
moondevover 2 years ago
Another gem from the same repo - gosh - pure golang shell<p>This means anywhere golang is installed, including aarch64 Darwin and Windows you can:<p><pre><code> go run mvdan.cc&#x2F;sh&#x2F;v3&#x2F;cmd&#x2F;gosh@latest </code></pre> Or things like<p><pre><code> go run mvdan.cc&#x2F;sh&#x2F;v3&#x2F;cmd&#x2F;gosh@latest -c &#x27;echo &quot;cross platform shell&quot;; go run github.com&#x2F;mikefarah&#x2F;yq&#x2F;v3@latest r metadata.name &lt;(kubectl get pod my-pod -o yaml)&#x27; </code></pre> Pretty awesome stuff, I&#x27;m always discovering new ways to use it.
评论 #34759660 未加载
js2over 2 years ago
I use shfmt and shellcheck together with pre-commit. I like to use the shfmt-py and shellcheck-py pre-commit hooks as opposed to <a href="https:&#x2F;&#x2F;github.com&#x2F;jumanjihouse&#x2F;pre-commit-hooks">https:&#x2F;&#x2F;github.com&#x2F;jumanjihouse&#x2F;pre-commit-hooks</a> as they&#x27;ll install the shfmt&#x2F;shellcheck prebuilt binaries as needed:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;maxwinterstein&#x2F;shfmt-py">https:&#x2F;&#x2F;github.com&#x2F;maxwinterstein&#x2F;shfmt-py</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;shellcheck-py&#x2F;shellcheck-py">https:&#x2F;&#x2F;github.com&#x2F;shellcheck-py&#x2F;shellcheck-py</a>
评论 #34759666 未加载
jeremy_wiebeover 2 years ago
And if you use fish, it comes with a built-in formatting function.<p><a href="https:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;current&#x2F;cmds&#x2F;fish_indent.html" rel="nofollow">https:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;current&#x2F;cmds&#x2F;fish_indent.html</a>
oweilerover 2 years ago
I&#x27;ve used it on a small project and it worked beautifully. It even understands and respects Bats syntax.
jmhollaover 2 years ago
Anybody have any luck building the image? It fails for me on podman and docker.
ufoover 2 years ago
Are there examples of what the formatted code looks like?
评论 #34756380 未加载
评论 #34756066 未加载
eschneiderover 2 years ago
Oooh, this looks fun.
typical182over 2 years ago
shfmt is like gofmt, rustfmt, ..., but for shell programs.<p>Supports bash, posix, mksh, bats.