Skip to content

shell option for execFile and execFileSync in child_process module not documented #18199

Description

@mojavelinux
  • Version: 8.9.4
  • Platform: n/a
  • Subsystem: child_process

The shell option for the execFile and execFileSync functions in the child_process module is not documented. However, it clearly works, as this mocha/chai test proves:

const { execFile, execFileSync } = require('child_process')
const expect = require('chai').expect

const EXEC_OPTS = { encoding: 'utf8', shell: process.env.SHELL }

describe('execFile()', () => {
  it('should run command using specified shell', async () => {
    let fn
    try {
      const result = await new Promise((resolve, reject) => {
        execFile('ls', ['*'], EXEC_OPTS, (err, stdout) =>
          err ? reject(err) : resolve(stdout))
      })
      fn = () => result
    } catch (err) {
      fn = () => { throw err }
    }
    expect(fn).to.not.throw()
  })
})

describe('execFileSync()', () => {
  it('should run command using specified shell', () => {
    expect(() => execFileSync('ls', ['*'], EXEC_OPTS)).to.not.throw()
  })
})

I'm happy to add documentation for this option. I just need to know if this behavior is intention or whether it's the result of leaky internals.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions