Results 1 to 2 of 2

Thread: Questions about inconsitencies with the PS1 in the default ~/.bashrc

  1. #1
    Join Date
    Feb 2019
    Beans
    3

    Question Questions about inconsitencies with the PS1 in the default ~/.bashrc

    Hi there!

    I came across a inconsistency that made wonder if it is intentional and I am misunderstanding something.
    In the default ~/.bashrc in my Ubuntu installation is the line
    Code:
    PS1='${debian_chroot:+($debian_chroot)}...'
    And a bit further down I can see
    Code:
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    Now I do understand what the `${debian_chroot:+($debian_chroot)}` stands for and what the different quotes mean ('-Quotes keep the variable literally, meaning it gets extended when the PS1 is being expanded/rendered and " expand it right there, meaning it the expanded result is directly in the PS1).
    But what I am wondering about is why it is added as a string in the first one and as a variable expansion in the second.
    From my (possibly limited) understanding it would make more sense to have the variables expanded late, so the second snippet should be
    Code:
    PS1='\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]'"$PS1"
    Or am I missing something here?

    If it's relevant I'm using Ubuntu 18.04.2 LTS.

  2. #2
    Join Date
    Feb 2019
    Beans
    3

    Re: Questions about inconsitencies with the PS1 in the default ~/.bashrc

    Bump

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •