Skip to content

Keep the job's locale inside QShell commands - #3565

Open
Juan-Concepcion wants to merge 1 commit into
codefori:masterfrom
Juan-Concepcion:fix/qsh-locale
Open

Juan-Concepcion wants to merge 1 commit into
codefori:masterfrom
Juan-Concepcion:fix/qsh-locale

Conversation

@Juan-Concepcion

Copy link
Copy Markdown

Fixes #3555

Changes

sendQsh starts qsh with LC_ALL=EN_US.UTF-8 in front of it. That prefix came in with #2546 to fix #2531, and it matters on the PASE side. But QShell inherits it too. QShell expects a locale object path (/QSYS.LIB/xx_XX.LOCALE), cannot resolve EN_US.UTF-8 (the CPFA0A9 ... EN_US.UTF-8 in the logs on #2519 is that lookup failing) and falls back to the C locale, which is CCSID 37.

Some pattern characters (| [ ] { } ^) sit at different positions in other EBCDIC code pages. On a job whose code page places them differently from 37 (273 and 280 are the two I tried), QShell reads them as the wrong bytes: grep with more than one -e term, or with a bracket expression, matches nothing and reports no error. That is #3555.

This change leaves the PASE invocation exactly as it is and adds unset LC_ALL as the first line of the script sent to QShell. QShell then uses the job's own locale from LANG, the same as a QSH session on a 5250.

Why this does not undo #2546: with LC_ALL set inside QShell to the EN_US, DE_DE, IT_IT or FR_FR locale paths, or to a value that does not exist, the bytes leaving qsh were identical every time. QShell's locale plays no part in the encoding of the output. The PASE side, which is what #2546 fixed, is untouched. The existing test that covers #2531 through sendQsh, "Run variants through shells", passes with this change on a 37 job and on a 273 job.

One visible side effect: commands that localize their output now follow the job's language, as they already do in the user's own QSH. On a German job, date printed Thu Dec 3 ... before and Don Dez 3 ... after. Nothing in the extension parses that output. attr -p, which getAttributes parses, is byte-identical before and after.

How to test this PR

Test cases. Two new tests in encoding.test.ts:

npx vitest run encoding -t "QShell"
  • "QShell keeps the job locale" fails before the change and passes after, on any system.
  • "Search patterns through QShell" fails before the change on a job whose code page differs from 37 (I ran it at 273), and passes after at 37 and at 273.

I ran them against PUB400. With the change, on a job at 273, the encoding suite passes 21 of 22. Across the encoding, content and connection suites, every failure I got also happens without the change and comes from PUB400 itself: "Listing objects with variants" (PUB400 does not allow CRTLIB), "should handle long library name" (no CREATE SCHEMA), and the two "Test runSQL" tests (a numeric column comes back as a string).

In the UI. Change the profile so the job is not at 37:

CHGPRF LOCALE('/QSYS.LIB/DE_DE.LOCALE') SETJOBATR(*CCSID *DATFMT *DATSEP *SRTSEQ *TIMSEP *DECFMT)

Add a user action that searches a source member for two words it contains (library, file and member below are placeholders):

{
  "name": "Locale probe",
  "command": "echo \"LC_ALL=[$LC_ALL]\"; /usr/bin/grep -c -i -F -e commit -e update /QSYS.LIB/MYLIB.LIB/QRPGLESRC.FILE/MYMBR.MBR; /usr/bin/grep -c -i -F -e commit /QSYS.LIB/MYLIB.LIB/QRPGLESRC.FILE/MYMBR.MBR; date",
  "extensions": ["GLOBAL"],
  "environment": "qsh",
  "type": "member"
}

Run it from the member's context menu. I ran it in two clean VS Code instances, one with 3.0.18 from the Marketplace and one with this PR's build:

3.0.18 this PR
LC_ALL inside QShell [EN_US.UTF-8] []
lines with commit or update 0 4
lines with commit 2 2
date Thu Dec 3 ... Don Dez 3 ...

3.0.18 also shows "Action Locale probe was successful": nothing fails, the search just finds nothing. On a 37 job both builds give 4 and 2.

Restore the profile afterwards:

CHGPRF CCSID(37) LOCALE('/QSYS.LIB/EN_US.LOCALE') SETJOBATR(*CCSID *DATFMT *DATSEP *SRTSEQ *TIMSEP *DECFMT)

The profile change reaches the next action without reconnecting.

Reproducing the mechanism without the extension. On a job at 37, from QSH, a locale whose code page differs from the job is enough:

cd $HOME
echo alpha > t.txt
echo beta >> t.txt
grep -c -e alpha -e beta t.txt                                 # 2
LC_ALL=/QSYS.LIB/IT_IT.LOCALE grep -c -e alpha -e beta t.txt   # 0

sendQsh creates the same mismatch on any job whose code page differs from 37, because QShell falls back to 37.

Not tested

The setup from #2531, a system without QIBM_PASE_CCSID. PUB400 sets it to 1208 system wide, so I could not reproduce that state. I expect no change there because the PASE side is untouched, but that is reasoning, not a test. Running the encoding suite on that system would settle it.

A system that sets LC_ALL itself at the ILE level. unset removes that too, but before this change the prefix overwrote it anyway, so nothing that worked stops working.

Checklist

  • have tested my change
  • have created one or more test cases
  • updated relevant documentation (no docs affected)
  • Remove any/all console.logs I added
  • have added myself to the contributors' list in CONTRIBUTING.md

@Juan-Concepcion
Juan-Concepcion deployed to testing_environment December 3, 2026 08:10 — with GitHub Actions Active
@sebjulliand sebjulliand added the bug A confirmed issue when something isn't working as intended label Dec 3, 2026

This branch was successfully deployed

1 active deployment
testing_environment — c0052572 Deployed Dec 3, 2026 by Juan-Concepcion via Test runner #819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A confirmed issue when something isn't working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendQsh forces LC_ALL=EN_US.UTF-8, which silently breaks grep patterns on jobs that are not CCSID 37 CCSID issue found in NLAURORABRATEST

2 participants