Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    Just to add to your question, even PS1='\ \$ ' returns the same prompt... So there are actually three cases where the prompt returns the same. Commented Jan 17, 2024 at 10:18
  • 1
    @aviro, \$ is not the same as just $, the former tells the shell to display a # if you're root, see gnu.org/software/bash/manual/html_node/… Commented Jan 17, 2024 at 12:10
  • The same part of the manual mentions that <backslash><backslash> should produce a backslash, so indeed it seems odd that <backslash><backslash><backslash><backslash> still produces only one, and not two. (Noting that you used single quotes, so the issue is not that one layer of backslash would be removed even before PS1 gets assigned.) Commented Jan 17, 2024 at 12:11
  • 1
    @ilkkachu sorry, I didn't copy the correct command, I mean PS1='\ $ '. Commented Jan 17, 2024 at 12:28
  • 1
    @aviro, yep, \ doing the same as \\ makes sense in that backslash-space is an unsupported escape and gets copied as-is. Same as within double-quotes. Commented Jan 17, 2024 at 13:22