Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11369

Re: Parameter Expansion: Case Modification: ${var~} not documented

From Dan Douglas <ormaaj@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Parameter Expansion: Case Modification: ${var~} not documented
Date 2015-08-18 09:22 -0500
Message-ID <mailman.8529.1439907735.904.bug-bash@gnu.org> (permalink)
References <CAO9HFd=EKGJ3KpuJtOcfWTn2F88ZFs=RUjjA9YF_rwJE9HY=gw@mail.gmail.com> <2003282.EDlDJ6aKWn@smorgbox>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Parameter Expansion: Case Modification: ${var~} not documented Dan Douglas <ormaaj@gmail.com> - 2015-08-18 09:22 -0500

csiph-web