Re: Behavior of ${var/*/text} has changed

2016-09-17 Thread Chet Ramey
On 9/16/16 3:06 PM, Eric Pruitt wrote: > Bash Version: 4.4 > Patch Level: 0 > Release Status: release > > Description: > In Bash 4.3, "${var/*/text}" would generate "" if var was a zero-length > string and "text" if it contained at least one character. In Bash 4.4, > this > is

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Eric Pruitt
On Fri, Sep 16, 2016 at 03:45:39PM -0400, Greg Wooledge wrote: > On Fri, Sep 16, 2016 at 12:38:20PM -0700, Eric Pruitt wrote: > > first time. However, that construct still won't work because if a > > variable is defined, it will still choose "not empty:" > > > > ericpruitt@sinister:~$ X= > >

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Greg Wooledge
On Fri, Sep 16, 2016 at 12:38:20PM -0700, Eric Pruitt wrote: > first time. However, that construct still won't work because if a > variable is defined, it will still choose "not empty:" > > ericpruitt@sinister:~$ X= > ericpruitt@sinister:~$ echo ${X+Not empty} > Not empty Then you wan

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Eric Pruitt
On Fri, Sep 16, 2016 at 12:30:59PM -0700, Eric Pruitt wrote: > > That, or ${VAR:+not empty} which is how I suggest testing for variable > > set-and-not-empty-ness. > > I'm aware of that construct, but that doesn't do what I want unless I'm > missing something; I don't want to change the value of th

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Greg Wooledge
On Fri, Sep 16, 2016 at 12:30:59PM -0700, Eric Pruitt wrote: > PS1="${SSH_TTY/?*/\\u@\\h:}\\W${jobs/?*/ [\\j]}\\$ " > > In this example, I want to show the username and hostname if SSH_TTY is > set and not empty, but I do not want to modify its value. I am also > showing the number of jobs

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Eric Pruitt
On Fri, Sep 16, 2016 at 03:22:29PM -0400, Greg Wooledge wrote: > Off hand I'd say the bash 4.4 behavior is correct. * matches 0 or > more characters, so it should match an empty or undefined variable. Yes, I agree that the Bash 4.4 behavior is more reasonable, but I think the change at least need

Re: Behavior of ${var/*/text} has changed

2016-09-16 Thread Greg Wooledge
On Fri, Sep 16, 2016 at 12:06:53PM -0700, Eric Pruitt wrote: > Bash 4.3: > ericpruitt@sinister:~$ VAR= > ericpruitt@sinister:~$ echo ${VAR/*/VAR was not empty} > > Bash 4.4: > ericpruitt@sinister:~$ VAR= > ericpruitt@sinister:~$ echo ${VAR/*/VAR was not e

Behavior of ${var/*/text} has changed

2016-09-16 Thread Eric Pruitt
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share