[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parameter Expansion: Case Modification: ${var~} not documented
From: |
Dan Douglas |
Subject: |
Re: Parameter Expansion: Case Modification: ${var~} not documented |
Date: |
Tue, 18 Aug 2015 09:22:07 -0500 |
User-agent: |
KMail/5.0.41 alpha1 (Linux/4.2.0-rc7; KDE/5.14.0; x86_64; ; ) |
On Tuesday, August 18, 2015 08:50:51 AM Dan Douglas wrote:
> I'm pretty sure that's intentional. The corresponding `declare -c` has never
> been documented either.
>
Hrm, it doesn't "correspond" actually. declare -c just capitalizes the first
letter of the string.
Another thing about the ${var~} expansions is I wonder why it isn't just built
in to the substitution expansion. The `~` is obviously inspired by the vim
movement to toggle caps. Given `foobarbaz`, vim can also do `:s/foo\zs\(bar\)
\zebaz/\U\1/` and yield `fooBARbaz`. This is much more powerful, though it
requires bash to start supporting backrefs in substitutions.
There's also this ksh feature I've never found a use for:
$ ksh -c 'x=foobarbaz; typeset -M toupper x; echo "$x"'
FOOBARBAZ
I don't know, the only purpose is to replace `typeset -l/-u` and allow for
other towctrans operations.
--
Dan Douglas