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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

The Five Meanings Of #. And What Does ${####} Mean?

3 点作者 subset超过 1 年前

1 comment

JNRowe超过 1 年前
There is a mid-level way to &quot;fix&quot; this under zsh, as it supports nesting parameter expressions¹. You can, for example, use ${#${#}} to disambiguate ${##}. It doesn&#x27;t remedy any of overloading described in the article, but it does at least make it possible to understand the implied meaning(rainbow highlighting for brackets probably helps here too).<p>For the most part I&#x27;d prefer the syntax suggested in the posted document, but I&#x27;m pointing this out as it can be useful as a way to apply arbitrary zsh flags to simple strings to remove the need for external tools like sed(fex, ${(<i>flags</i>)${:-test}:<i>flags</i>}).<p>Final odd trivia note, you can make the syntax even worse with zsh as # is also an expansion flag when surrounded by braces. ${(#)#:-0x23} is valid -- and woefully unreadable -- syntax to count the length of the &quot;#&quot; string.<p>¹ <a href="https:&#x2F;&#x2F;zsh.sourceforge.io&#x2F;Doc&#x2F;Release&#x2F;Expansion.html#Rules" rel="nofollow noreferrer">https:&#x2F;&#x2F;zsh.sourceforge.io&#x2F;Doc&#x2F;Release&#x2F;Expansion.html#Rules</a>