[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Greg Wooledge
Subject: Re: Behavior of ${var/*/text} has changed
Date: Fri, 16 Sep 2016 15:38:04 -0400
User-agent: Mutt/

On Fri, Sep 16, 2016 at 12:30:59PM -0700, Eric Pruitt wrote:
>         PS1="${SSH_TTY/?*/address@hidden:}\\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 in brackets, but I only want to do that if
> there are some jobs in the background.

You're confusing :+ with :=

imadev:~$ echo "$BASH_VERSION"
imadev:~$ unset undefined; defined=yes; empty=  
imadev:~$ echo "<${undefined:+a}> <${defined:+b}> <${empty:+c}>"
<> <b> <>
imadev:~$ echo "<${undefined+a}> <${defined+b}> <${empty+c}>"
<> <b> <c>
imadev:~$ declare -p undefined defined empty
bash: declare: undefined: not found
declare -- defined="yes"
declare -- empty=""

reply via email to

[Prev in Thread] Current Thread [Next in Thread]