In 73e06b9d4c (bash.bashrc: Update PS1 if PS1 wasn't exported. Closes
#653, 2016-07-14), we updated `/etc/bash.bashrc` to avoid overriding
`PS1`, but the way it was done requires `cut.exe` to be in the `PATH`.
Now, while _most_ of the time we're running inside a login Bash where
the `PATH` has been appropriately modified, sometimes we don't. In that
case, `cut.exe` is not in the `PATH`.
We should not spawn a new process, anyway, as spawning processes is
really expensive in the MSYS2 runtime because of all the contortions
necessary to emulate the POSIX syscall `fork()`.
Let's just avoid that extra process by using `case`, which is a Bash
built-in and therefore won't cost much time to run.
This fixes https://github.com/git-for-windows/git/issues/3652
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
If msys2 bash is set as the DefaultShell for the Win10 OpenSSH server,
there is no way to pass -l to make it a login shell, so /etc/profile is
not sourced, PATH is not set, and the bashrc produces errors.
Detect this case in /etc/bash.bashrc, by checking for the SSH_CONNECTION
environment variable and PATH not having msys2 elements, and source
/etc/profile.
6e6310d (filesystem: New specific variable MSYS2_PS1., 2016-05-01)
introduced the MSYS2_PS1 prompt script priority to allow multiple
device configurations.
Unfortunately, if MSYS2_PS1 was not set it overwrote the $PS1, even
when specifically set by the users configuration, such as provided in the
Git-for-Windows SDK (see https://github.com/git-for-windows/git/issues/794#issuecomment-227401839)
and the monkey patch fix (https://github.com/git-for-windows/build-extra/pull/122).
Introduce a priority order so that the user's $PS1 (if set) has an
intermediate priority between the MSYS2_PS1 and the default PS1.
Signed-off-by: Philip Oakley <philipoakley@iee.org>
* Warning about required shortcut changes.
When upgrading the filesystem package, user will be notified about the
unified msys2_shell.cmd and asked for updating their shortcuts.
* New warning mechanism for interactive bash sessions.
Applications can now add warnings to the terminal for notifying the
user about possible problems. This is done by adding a file containing
the warning text to one of the following locations:
- /etc/profile.d/NAME.warning
- /mingw32/etc/profile.d/NAME.warning
- /mingw64/etc/profile.d/NAME.warning
These files are processed by /etc/bash.bashrc. Files with the
"warning.once" extension are removed after processing. An
implementation example is provided by next change.
* Add simplified parameter -full-path to msys2_shell.cmd. The old
parameter -use-full-path still works for now but is marked as
deprecated using the above warning mechanism.
* Add file opening support to shell manager.
Both directory and file arguments are now accepted and passed to
Windows Explorer for opening with default application.
* Residual pkgrel updates.
Setting this variable now makes /etc/bash.bashrc use that as PS1 instead
of default value. This allows for configuration shared between MSYS2 and
other environments like Cygwin or MinGW.org MSYS to define a PS1 that is
specific to MSYS2 without manual detection of the system type.