Skip to content

[Documentation] Update exec.exec documentation to mention single quote limitation #1382

Open
@aeroastro

Description

@aeroastro

Describe the enhancement

The current documentation of exec.exec does not mention the limitation
regarding single quotes and double quotes. In the current implementation,
only double quotes are supported for splitting arguments.

The documentation should be updated to include
this information to prevent confusion and save developers' time.

Current document on exec.exec is as follows.

/**
* Exec a command.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code
*/

 * @param     commandLine        command to execute (can include additional args). Must be correctly escaped.

This lacks information on single quotes and double quotes, only the latter of which is supported currently. I would like to append the information on the doc.

Code Snippet

 * @param     commandLine        command to execute (can include additional args). Must be correctly escaped. Currently, only double quotes are supported for splitting args.

Additional information

I spent many hours debugging the reason why the following code did not work as expected

exec.exec(`git config --local some.key 'some value with white space'`)

It is only after I read the internal code that I realized the root cause is the single quotes.
I believe the slight change on doc can prevent developers like me from failing into pitfalls.

// we only escape double quotes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions