On Mon, 4 May 2015 00:02:11 -0600 Bob Proulx <b...@proulx.com> wrote:
> Petter Adsen wrote: > > Brad Rogers wrote: > > > PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\ > > > [\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' > > > > Excuse me if this is a dumb question, but what does the > > "debian_chroot" part (twice) do? > > Basic shell substitution. The task there is to include "(foo)" in the > prompt if debian_chroot is set to foo. Initially you might think, I > will use $debian_chroot and if it is empty then it will be empty and > if it is set to foo then it will expand to foo. Almost works. That > would expand to "foo" not "(foo)" with the parens around it. > <snip for brevity> > The ${parameter:+word} construct is used a lot of shell programming. > > Editorial remark: I really wish the author of /etc/debian_chroot had > simply made that /etc/chroot_name or some such. Because by naming it > /etc/debian_chroot guarantees that no other distribution will pick > that convention up and use it. If it had been /etc/chroot_name or > something non-distribution specific then it would have been possible > to share across other distributions. Sigh. Bob, Thank you very much for your detailed explanation, it was very enlightening. Just recently, I downloaded all the bash documentation from tdlp.org and have slowly begin making my way through it. As a rule, I don't like putting things in my scripts that I do not understand, and this was a very nice feature. Thanks again, Petter -- "I'm ionized" "Are you sure?" "I'm positive."
pgppL_qvFRqM_.pgp
Description: OpenPGP digital signature