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.

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

3 pointsby subsetover 1 year ago

1 comment

JNRoweover 1 year ago
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>