Skip to content

Commit db47559

Browse files
me-andjon-turney
authored andcommitted
Allow keeping Cygwin out of PATH
In some circumstances, it might be useful to have Cygwin installed, but not have its executables take precedence over pre-installed packages. Add an "add-to-path" option that, if set to "false", will skip the step of adding Cygwin's /bin directory to PATH. Also update documentation to mention this option, and update the test scripts to check it works as expected; the default behaviour is tested as part of the "install-dir-test", and the new behaviour as part of the main test.
1 parent f5e0f04 commit db47559

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
with:
3232
platform: ${{ matrix.platform }}
3333
packages: ${{ matrix.packages }}
34+
add-to-path: false
3435

3536
- name: Explicitly running shell
3637
run: C:\cygwin\bin\bash -lc "echo 'Explicitly run shell'"
@@ -52,6 +53,21 @@ jobs:
5253
run: C:\cygwin\bin\sponge.exe tmp
5354
if: contains(matrix.packages, 'moreutils')
5455

56+
- name: Check PATH hasn't changed
57+
run: |
58+
if [[ "${OSTYPE}" = "cygwin" ]]; then
59+
echo "unexpectedly using Cygwin Bash"
60+
exit 1
61+
fi
62+
63+
if [[ "$(cygpath -aw "$(which cygpath)")" = 'C:\cygwin\'* ]]; then
64+
echo "unexpectedly using Cygwin cygpath"
65+
exit 1
66+
fi
67+
shell: bash # If Cygwin is not in PATH -- as expected -- this will be Git Bash
68+
env:
69+
SHELLOPTS: igncr
70+
5571
complex-test:
5672
runs-on: windows-latest
5773
name: 'Complex Test'

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Parameters
2525
| install-dir | C:\cygwin | Installation directory
2626
| site | http://mirrors.kernel.org/sourceware/cygwin/ | Mirror site to install from
2727
| check-sig | true | Whether to check the setup.ini signature
28+
| add-to-path | true | Whether to add Cygwin's `/bin` directory to the system `PATH`
2829

2930
Line endings
3031
------------
@@ -52,7 +53,7 @@ Alternatively, you can also use:
5253
PATH
5354
----
5455

55-
This action prepends Cygwin's /usr/bin directory to the PATH.
56+
By default, this action prepends Cygwin's /usr/bin directory to the PATH.
5657

5758
However, if you want to ensure that PATH only contains Cygwin executables,
5859
and other stuff installed in the VM image isn't going to get picked up:
@@ -69,6 +70,8 @@ or,
6970
* prevent the profile script from changing directory by putting
7071
`CHERE_INVOKING` into the environment
7172

73+
If you want the opposite – the system PATH to remain unchanged by this action – add `add-to-path: false` to the action settings.
74+
7275
Symlinks
7376
--------
7477

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
site:
2323
description: Download site URL
2424
required: false
25+
add-to-path:
26+
description: Should Cygwin's bin directory be added to the system PATH?
27+
required: false
28+
default: true
2529

2630
runs:
2731
using: "composite"
@@ -78,8 +82,11 @@ runs:
7882
& C:\setup.exe $args | Out-Default
7983
shell: powershell
8084
85+
- if: ${{ inputs.add-to-path == 'true' }}
86+
run: echo "${{ inputs.install-dir }}\bin" >> $env:GITHUB_PATH
87+
shell: powershell
88+
8189
- run: |
82-
echo "${{ inputs.install-dir }}\bin" >> $env:GITHUB_PATH
8390
# run login shell to copy skeleton profile files
8491
${{ inputs.install-dir }}\bin\bash.exe --login
8592
shell: powershell

0 commit comments

Comments
 (0)