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
When I use
\nafter command substitution in$PS1, it causes syntax error:It should not cause the error.
If I remove the
\nafter$(date), it works fine:Using backquotes instead of
$()also works fine: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