Make WordPress Core

Opened 4 years ago

Last modified 8 months ago

#49491 new defect (bug)

Escape command arguments of env:cli before passing to docker-compose

Reported by: ocean90's profile ocean90 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.3
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:


npm run env:cli option update blogname "foo bar" currently fails with "Error: Too many positional arguments: bar". This is because "foo bar" isn't passed with the quotes to docker-compose.

> WordPress@5.4.0 env:cli /WordPress/wordpress-core
> node ./tools/local-env/scripts/docker.js run cli "option" "update" "blogname" "foo bar"

Error: Too many positional arguments: bar
    throw err;

Error: Command failed: docker-compose run cli option update blogname foo bar
    at checkExecSyncError (child_process.js:621:11)
    at execSync (child_process.js:657:15)
    at Object.<anonymous> (/WordPress/wordpress-core/tools/local-env/scripts/docker.js:6:1)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 32760,
  stdout: null,
  stderr: null

Maybe we can use something like

Attachments (1)

12345.diff (717 bytes) - added by zaerl 8 months ago.

Download all attachments as: .zip

Change History (4)

#1 @bgoewert
19 months ago

@ocean90 does this work?

npm run env:cli "option update blogname 'foo bar'"

#2 @maliev
13 months ago

I would try to replace this line in the package.json inside of this section:

"env:cli": "node ./tools/local-env/scripts/docker.js run cli \"${1}\" \"${2}\" \"${3}\" \"${4}\""

8 months ago

#3 @zaerl
8 months ago

  • Keywords has-patch added; needs-patch removed

I've mapped the arguments passed to execSync so that if an argument contains spaces, it will be treated as a single argument by the shell.

Note: See TracTickets for help on using tickets.