Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

spaces not escaped property #143

Closed
derekgreer opened this issue Sep 18, 2017 · 3 comments
Closed

spaces not escaped property #143

derekgreer opened this issue Sep 18, 2017 · 3 comments

Comments

@derekgreer
Copy link

  • cross-env version: 5.0.5
  • node version: v6.11.2
  • yarn version: 0.27.5
  • platform: Windows
  • shell: bash

Relevant code or config

{
  "name": "issue",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "test0": "printf \"[%s]\\n\" \"%npm_package_main% %npm_package_version%\"",
    "test1": "cross-run printf \"[%s]\\n\" \"%npm_package_main% %npm_package_version%\"",
    "test2": "cross-env-shell cross-run printf \"[%s]\\n\" \"${npm_package_main} ${npm_package_version}\"",
    "test3": "cross-env-shell cross-run printf \"[%s]\\n\" \"${npm_package_main}\\ ${npm_package_version}\"",
    "test4": "cross-run cross-run printf \"[%s]\\n\" \"%npm_package_main% %npm_package_version%\""
  },
  "devDependencies": {
    "cross-env": "^5.0.5",
    "cross-run": "^1.0.1"
  }
}

What you did:

$> yarn run test2

What was expected:

[index.js 1.0.0]

What happened:

[index.js]
[1.0.0]

Problem description:

I've got a script that has spaces in the arguments I can't seem to get quoted. I've included several tests in the script which seems to pinpoint the issue being with cross-env-shell. To perform a similar scenario, test4 passes the output of cross-run to itself again which still prints the expected output of [index.js 1.0.0]. The issue seems to be that cross-env-shell isn't preserving the argument list correctly.

@kentcdodds
Copy link
Owner

Interesting! Thanks for filling the issue!

Do you think you could make a pull request to fix this?

@arthurcavallari
Copy link

arthurcavallari commented Mar 1, 2018

@derekgreer You need to use triple backslash when wrapping your commands in quotes, as stated in the docs.

Notice I changed \" to \\\" before ${npm_package_main} and after ${npm_package_version}

    "test2": "cross-env-shell cross-run printf \"[%s]\\n\" \\\"${npm_package_main} ${npm_package_version}\\\"",

@kentcdodds
Copy link
Owner

Thanks @arthurcavallari! I'm going to go ahead and close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants