Re: How to force BASH to re-evaluate PS1

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

 



TK wrote:

Lets say:

PS1="[${INSTALL_DIR##*/}]"

Bash is able to evalute it for the first time; but later, after INSTALL_DIR's value changes, Bash prompt wouldn't change accordingly. So is there a systematic way to force BASH to reflect the change?

Thanks.
-tk


5 minutes after sending out the email, I think I've just found the answer:
PS1="[\${INSTALL_DIR##*/}]"

The reason seems to be that "\$" makes a literal "$" so shell doesn't expand the "${}" immediately, which gives it a second chance for evaluation upon each new prompt.

Shell expansion/substitution has been confusing to me, since the KSH days, and it continues to be :)

-tk



--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux