diff --git a/src/config/config.ts b/src/config/config.ts index cdde8ea3a..6f3aafba8 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -18,6 +18,8 @@ import {CompletableOptionFlag, Arg} from '../interfaces/parser' import {stdout} from '../cli-ux/stream' import {Performance} from '../performance' import {settings} from '../settings' +import {userInfo as osUserInfo} from 'node:os' +import {sep} from 'node:path' // eslint-disable-next-line new-cap const debug = Debug() @@ -550,7 +552,8 @@ export class Config implements IConfig { protected _shell(): string { let shellPath - const {SHELL, COMSPEC} = process.env + const COMSPEC = process.env.COMSPEC + const SHELL = process.env.SHELL ?? osUserInfo().shell?.split(sep)?.pop() if (SHELL) { shellPath = SHELL.split('/') } else if (this.windows && COMSPEC) { diff --git a/test/config/config.shell.test.ts b/test/config/config.shell.test.ts new file mode 100644 index 000000000..421105c23 --- /dev/null +++ b/test/config/config.shell.test.ts @@ -0,0 +1,14 @@ +import {expect} from 'chai' +import {Config} from '../../src' +import {userInfo as osUserInfo} from 'node:os' +import {sep} from 'node:path' + +const getShell = () => osUserInfo().shell?.split(sep)?.pop() || 'unknown' + +describe('config shell', () => { + it('has a default shell', () => { + const config = new Config({root: '/tmp'}) + // @ts-ignore + expect(config._shell()).to.equal(getShell(), `SHELL: ${process.env.SHELL} COMSPEC: ${process.env.COMSPEC}`) + }) +})