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 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