TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Shfmt – format shell programs

115 点作者 typical182超过 2 年前

9 条评论

VWWHFSfQ超过 2 年前
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 未加载
moondev超过 2 年前
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 未加载
js2超过 2 年前
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_wiebe超过 2 年前
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>
oweiler超过 2 年前
I&#x27;ve used it on a small project and it worked beautifully. It even understands and respects Bats syntax.
jmholla超过 2 年前
Anybody have any luck building the image? It fails for me on podman and docker.
ufo超过 2 年前
Are there examples of what the formatted code looks like?
评论 #34756380 未加载
评论 #34756066 未加载
eschneider超过 2 年前
Oooh, this looks fun.
typical182超过 2 年前
shfmt is like gofmt, rustfmt, ..., but for shell programs.<p>Supports bash, posix, mksh, bats.