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

cross-env eats backslashes #167

Closed
greggman opened this issue Feb 9, 2018 · 6 comments
Closed

cross-env eats backslashes #167

greggman opened this issue Feb 9, 2018 · 6 comments

Comments

@greggman
Copy link
Contributor

greggman commented Feb 9, 2018

  • cross-env version: 5.1.3
  • node version: 8.9.4
  • npm (or yarn) version: 5.6.0

Relevant code or config, in package.json

{
  "name": "test-cross-env",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test1": "cross-env TEST=foo node main.js",
    "test2": "node main.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cross-env": "^5.1.3"
  }
}

main.js

console.log(process.argv.join(' '));

What you did:

passed \\someshare\somefolder through cross-env

What happened:

cross-env ate a backslash

C:\Users\gregg\temp>npm run test1 -- \\someshare\somefolder

> test-cross-env@1.0.0 test1 C:\Users\gregg\temp
> cross-env TEST=foo node main.js "\\someshare\somefolder"

C:\Program Files\nodejs\node.exe C:\Users\gregg\temp\main.js \someshare\somefolder

C:\Users\gregg\temp>npm run test2 -- \\someshare\somefolder

> test-cross-env@1.0.0 test2 C:\Users\gregg\temp
> node main.js "\\someshare\somefolder"

C:\Program Files\nodejs\node.exe C:\Users\gregg\temp\main.js \\someshare\somefolder

Reproduction repository:

see above

Problem description:

cross-env eats backslashes. Not going through cross-env the backslashes make it into the program being excecuted

You can't even escape them with more backslashes

C:\Users\gregg\temp>npm run test1 -- \\\\someshare\somefolder

> test-cross-env@1.0.0 test1 C:\Users\gregg\temp
> cross-env TEST=foo node main.js "\\\\someshare\somefolder"

C:\Program Files\nodejs\node.exe C:\Users\gregg\temp\main.js \someshare\somefolder
@rob3c
Copy link

rob3c commented Mar 8, 2018

Normally, you pass args to npm scripts via --, as shown in the npm docs here:

https://docs.npmjs.com/cli/run-script

Otherwise, you're just passing the args to npm, not your script. If they make it through somehow, then you probably got lucky.

Have you tried the documented way like this?:

> npm run test1 -- \\someshare\somefolder

@greggman
Copy link
Contributor Author

greggman commented Mar 9, 2018

Sorry, there was a typo in my original message. I was using -- Why don't you actually try it and you'll see the bug

cross-env-bug

@kentcdodds
Copy link
Owner

Yes, looks like it's probably a legit bug. Feel free to make a pull request to fix this :)

@rob3c
Copy link

rob3c commented Mar 21, 2018

@greggman LOL at the thumbs down for trying to give you legitimate advice for the code you actually posted. Your 'typo' makes a huge difference in the behavior, but I guess we're supposed to read your mind instead of your text.

@greggman
Copy link
Contributor Author

sorry I tried to helpful. won't bother next time

@kentcdodds
Copy link
Owner

@rob3c, that tone was unappreciated. Thank you both for trying to be helpful in general.

Repository owner locked as resolved and limited conversation to collaborators Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants