Skip to content

Commit 1c12f33

Browse files
committed
Ensure that grep -P works
The `--perl-regexp` option of `grep` requires a "unibyte or UTF-8" locale, simply refusing to work at all if neither `LANG`, `LC_ALL` nor `LC_CTYPE` are set. Typically, this would not be a problem because `/etc/profile` ensures that `LC_CTYPE` is set. But GitHub workflows call `bash` with `-noprofile`, therefore we need to do set `LC_CTYPE` here. Just like `/etc/profile` does, we won't override any locale the user might have configured explicitly. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2b730dd commit 1c12f33

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ jobs:
5151
gcc -o hello-world.exe hello-world.c
5252
hello="$(./hello-world.exe)"
5353
test 'Hello, world!' = "$hello"
54+
55+
# Verify that the locale is set, enabling `grep -P` to work
56+
test 123 = "$(printf '1248\n123\n' | grep -P '2(?!4)')"

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cSpell.ignoreRegExpList": [
33
"CHERE_INVOKING",
4+
"LC_CTYPE",
45
"SDK's",
56
"makepkg-git",
67
"mingw-w64-git",

main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ async function run(): Promise<void> {
6262
const msystem = architecture === 'i686' ? 'MINGW32' : 'MINGW64'
6363
core.addPath(`${outputDirectory}/${msystem.toLocaleLowerCase()}/bin`)
6464
core.exportVariable('MSYSTEM', msystem)
65+
if (
66+
!('LANG' in process.env) &&
67+
!('LC_ALL' in process.env) &&
68+
!('LC_CTYPE' in process.env)
69+
) {
70+
core.exportVariable('LC_CTYPE', 'C.UTF-8')
71+
}
6572
} catch (error) {
6673
core.setFailed(error.message)
6774
}

0 commit comments

Comments
 (0)