Re: tree with dir size
On Mon 03 Jun 2024 at 10:32:16 (-0400), Greg Wooledge wrote:
> I'll also throw in one last piece of information because if I don't,
> someone else is likely to do it, without a good explanation.
> Syntactically, the body of a shell function doesn't have to be enclosed
> in curly braces. The body can be any compound command, and a curly-brace
> command group is just one example of a compound command. A subshell is
> another example. So, it could also be written this way:
>
> duhs() (
> shopt -s dotglob
> printf '%s\0' "${1:-.}"/*/ | xargs -0 du -sh
> )
>
> I'm not personally fond of this. It's extremely easy to overlook
> the fact that the curly braces have been replaced with parentheses,
> especially in certain fonts. Nevertheless, some people like this.
I guess minimalists would make a one-liner out of that.
Myself, I prefer verbosity, and the ability to search and find
all my functions with /function.*{$ in less. For example,
I write what is probably my most trivial function in .bashrc as:
function _Cat_ {
cat
}
rather than:
_Cat_() { cat; }
Cheers,
David.
Reply to: