Skip to content

Commit 25475bf

Browse files
authored
Apply login-shell -l flag when args array is empty (#40)
2 parents 8c739bf + 3259b8b commit 25475bf

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

standalone/sidecar/pty-core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ function resolveSpawnConfig(options, runtime = {}) {
6363
const defaultCwd = resolveDefaultCwd(platform, env, osModule);
6464
const missingExplicitCwd = Boolean(cwd) && !directoryExists(cwd, fsModule);
6565
const shell = explicitShell || resolveDefaultShell(platform, env);
66-
const shellArgs = explicitArgs || resolveLoginArg(shell, platform);
66+
// An empty array means "no override," not "no args" — fall through to the
67+
// login-flag default so `~/.zprofile` runs and PATH includes Homebrew/asdf.
68+
const shellArgs = explicitArgs && explicitArgs.length > 0
69+
? explicitArgs
70+
: resolveLoginArg(shell, platform);
6771

6872
return {
6973
cols,

standalone/sidecar/pty-core.test.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,27 @@ test('resolveSpawnConfig falls back to the default directory when explicit cwd i
100100
assert.equal(config.rows, 40);
101101
});
102102

103+
test('resolveSpawnConfig treats empty args array as no-override and applies -l', () => {
104+
// Regression: detectAvailableShells returns args:[] on Unix, which used to
105+
// suppress the -l fallback (empty array is truthy). That caused the login
106+
// shell to skip ~/.zprofile, leaving Homebrew/asdf off PATH and producing
107+
// "asdf_update_java_home: command not found: asdf" on every prompt.
108+
const config = resolveSpawnConfig(
109+
{ args: [] },
110+
{
111+
platform: 'darwin',
112+
env: { SHELL: '/bin/zsh' },
113+
osModule: {
114+
homedir: () => '/Users/tester',
115+
tmpdir: () => '/tmp/fallback',
116+
},
117+
},
118+
);
119+
120+
assert.equal(config.shell, '/bin/zsh');
121+
assert.deepEqual(config.shellArgs, ['-l']);
122+
});
123+
103124
test('resolveSpawnConfig skips -l for csh', () => {
104125
const config = resolveSpawnConfig(undefined, {
105126
platform: 'darwin',
@@ -223,21 +244,20 @@ test('resolveSpawnConfig uses explicit shell with default args fallback', () =>
223244
assert.deepEqual(config.shellArgs, ['-l']);
224245
});
225246

226-
test('resolveSpawnConfig uses explicit args with empty array', () => {
247+
test('resolveSpawnConfig honors non-empty explicit args (e.g. WSL distro flags)', () => {
227248
const config = resolveSpawnConfig(
228-
{ args: [] },
249+
{ args: ['-d', 'Ubuntu'] },
229250
{
230-
platform: 'linux',
231-
env: { SHELL: '/bin/bash' },
251+
platform: 'win32',
252+
env: {},
232253
osModule: {
233-
homedir: () => '/home/tester',
234-
tmpdir: () => '/tmp/fallback',
254+
homedir: () => 'C:\\Users\\tester',
255+
tmpdir: () => 'C:\\Temp',
235256
},
236257
},
237258
);
238259

239-
assert.equal(config.shell, '/bin/bash');
240-
assert.deepEqual(config.shellArgs, []);
260+
assert.deepEqual(config.shellArgs, ['-d', 'Ubuntu']);
241261
});
242262

243263
// ── detectAvailableShells ───────────────────────────────────────────────

0 commit comments

Comments
 (0)