Skip to content

bash: '\n' after command substitution in $PS1 causes error #1839

Open
@k-takata

Description

@k-takata

When I use \n after command substitution in $PS1, it causes syntax error:

$ PS1='$(date)\n\$ '
-bash: command substitution: line 1: syntax error near unexpected token `)'
-bash: command substitution: line 1: `date)'

It should not cause the error.
If I remove the \n after $(date), it works fine:

$ PS1='$(date)\$ '
Mon Jan 27 19:16:55 JST 2020$ 

Using backquotes instead of $() also works fine:

$ PS1='`date`\n\$ '
Mon Jan 27 19:21:51 JST 2020
$ 

Setting PS1='$(date)\n\$ ' works fine on Cygwin, so this seems an MSYS2 specific issue.

See also: https://stackoverflow.com/questions/21517281/ps1-command-substitution-fails-when-containing-newlines-on-msys-bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions