Re: [ping] declare -c still undocumented.

2020-11-13 Thread Chet Ramey

On 11/13/20 3:50 PM, L A Walsh wrote:

On 2020/11/13 09:01, Chet Ramey wrote:

On 11/12/20 6:19 PM, Léa Gris wrote:
declare -c to capitalize first character of string in variable 


Thanks for the reminder. I keep forgetting to turn this off. It's too late
for bash-5.1, but I have it tagged to flip to disabled by default in
config-top.h in bash-5.2.

---
    It is replaced with something else?


There's nothing to directly replace `declare -c', which was a bad idea to
begin with. You can use the new @u parameter transformation operator to
replace ${v~}. The ability to use the pattern in @{v~[pattern]} wasn't a
great idea either.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: [ping] declare -c still undocumented.

2020-11-13 Thread L A Walsh

On 2020/11/13 09:01, Chet Ramey wrote:

On 11/12/20 6:19 PM, Léa Gris wrote:
  
declare -c to capitalize first character of string in variable 



Thanks for the reminder. I keep forgetting to turn this off. It's too late
for bash-5.1, but I have it tagged to flip to disabled by default in
config-top.h in bash-5.2.
  

---
   It is replaced with something else?






Re: [ping] declare -c still undocumented.

2020-11-13 Thread Chet Ramey
On 11/12/20 6:19 PM, Léa Gris wrote:
> Necroposting for still valid issue:
> 
> declare -c to capitalize first character of string in variable is still
> undocumented as of GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

Thanks for the reminder. I keep forgetting to turn this off. It's too late
for bash-5.1, but I have it tagged to flip to disabled by default in
config-top.h in bash-5.2.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: set -e in subshell

2020-11-13 Thread Aron Griffis
On Fri, Nov 13, 2020 at 11:31 AM Chet Ramey  wrote:

> `set -e' doesn't have any effect on the LHS of an and-or list, and enabling
> it has no effect. There have been many discussions about this.
>

Thanks Chet. I knew about this generally, but somehow thought subshell
would be exempt. I will adjust my expectation :-)

Regards,
Aron


Re: set -e in subshell

2020-11-13 Thread Chet Ramey
On 11/13/20 11:15 AM, Aron Griffis wrote:
> GNU bash, version 5.0.17(1)-release (x86_64-redhat-linux-gnu)
> 
> $ (set -e; false; echo BANG) || echo whimper
> BANG

`set -e' doesn't have any effect on the LHS of an and-or list, and enabling
it has no effect. There have been many discussions about this.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



set -e in subshell

2020-11-13 Thread Aron Griffis
GNU bash, version 5.0.17(1)-release (x86_64-redhat-linux-gnu)

$ (set -e; false; echo BANG) || echo whimper
BANG

$ (set -e; false; echo BANG); echo whimper
whimper

The || after the subshell seems to prevent set -e from being effective
inside the subshell.

Is this a bug or does it make sense in a way I don't understand?

Thanks,
Aron


Re: [ping] declare -c still undocumented.

2020-11-13 Thread Léa Gris

Le 13/11/2020 à 12:47, Chris Elvidge écrivait :
But ${var^} still doesn't know that it should apply to the first alpha 
character in a string. Similar for , and ~. If the first character of 
the string is a punctuation character, e.g.(, it doesn't work (as I 
would like it to ).


Well, you are diverging from the issue here. I suggest you create a 
distinct post to discuss your feature request.


To Chet,
The feature survived from Bash 4.0 to 5.0.
Are you still uncertain about the declare -c attribute's status?

Anyway, here is what I found in a conversation from 2009:

Available here: 




Re: "declare -c" not documented
From:   Chet Ramey
Subject:Re: "declare -c" not documented
Date:   Thu, 19 Mar 2009 09:37:06 -0400
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

Greg Wooledge wrote:

The -c option for declare (new in bash 4.0) is not mentioned in either
the man page or the "help declare" text.


Correct.  I'm not sure the capitalization feature will survive.  If it
makes it into the next version, I will add the documentation.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRUaddress@hiddenhttp://cnswww.cns.cwru.edu/~chet/






--
Léa Gris




Re: [ping] declare -c still undocumented.

2020-11-13 Thread Chris Elvidge

On 13/11/2020 09:33 am, felix wrote:

On Fri, Nov 13, 2020 at 12:19:27AM +0100, Léa Gris wrote:


Happy 10 years 10 months anniversary to the issue:




 address@hidden:~$ declare -c moo=moo; echo $moo
 Moo


   cap() { local -ca _cap=("$@");echo ${_cap[*]};}
   cap great éric.
   Great Éric.

Like this:
   https://lists.gnu.org/archive/html/bug-bash/2010-02/msg00081.html

   ${parameter:~pattern}  Toggle case of 1st character if matching optional 
pattern
   ${parameter:~~pattern} Toggle case of all characters regarding pattern:

   cap() { local -cl _cap=("$@");echo ${_cap[*]~};}
   cap great éric.
   Great Éric.

   myvar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; echo 
${myvar~~[H-p]}
   ABCDEFGhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPqrstuvwxyz




But ${var^} still doesn't know that it should apply to the first alpha 
character in a string. Similar for , and ~. If the first character of 
the string is a punctuation character, e.g.(, it doesn't work (as I 
would like it to ).


--
Chris Elvidge
England




Re: [ping] declare -c still undocumented.

2020-11-13 Thread felix
On Fri, Nov 13, 2020 at 12:19:27AM +0100, Léa Gris wrote:
> 
> Happy 10 years 10 months anniversary to the issue:
> 
> 
> 
> > address@hidden:~$ declare -c moo=moo; echo $moo
> > Moo

  cap() { local -ca _cap=("$@");echo ${_cap[*]};}
  cap great éric.
  Great Éric.

Like this:
  https://lists.gnu.org/archive/html/bug-bash/2010-02/msg00081.html

  ${parameter:~pattern}  Toggle case of 1st character if matching optional 
pattern
  ${parameter:~~pattern} Toggle case of all characters regarding pattern:

  cap() { local -cl _cap=("$@");echo ${_cap[*]~};}
  cap great éric. 
  Great Éric.

  myvar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; echo 
${myvar~~[H-p]}
  ABCDEFGhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPqrstuvwxyz


-- 
 Félix Hauri  --  http://www.f-hauri.ch