Skip to content

Dollar sign get removed from process.argv on transpilation #1874

Closed

Description

@OlivierCuyp

Search Terms

process.argv script argument dollar sign $

Expected Behavior

Keep $ in process.argv when it correctly passed to script argument.

Actual Behavior

When creating a script that takes arguments, and if an argument is passed with a $, it disappear from it in process.argv.

Steps to reproduce the problem

  1. Create a script that logs process.argv
  2. Run the script with an argument containing a $

Minimal reproduction

dollar.ts:

console.log(process.argv);

execution (in bash terminal):

> npx ts-node ./scripts/dollar.ts --test='$7test'
[
  '/Users/me/project/scripts/node_modules/.bin/ts-node',
  '/Users/me/project/scripts/dollar.ts',
  '--test=test' // <---  '$7' disappeared
]

In pure JS, there is no issue with the same script:

> node ./scripts/dollar.js --test='$7test'
[
  '/Users/me/project/scripts/node_modules/.bin/ts-node',
  '/Users/me/project/scripts/dollar.ts',
  '--test=$7test' // <--- all good !
]

Specifications

  • ts-node version: 10.9.1
  • node version: 16.15.1
  • TypeScript version: 4.8.2
  • tsconfig.json, if you're using one:
{
  "ts-node": {
    "files": true,
    "transpileOnly": true
  },
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "sourceMap": true,
    "strict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true
  }
}
  • package.json:
{
  "name": "dollar",
  "version": "1.0.0",
  "description": "",
  "main": "dollar.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ts-node": "^10.9.1",
    "typescript": "^4.8.2"
  }
}
  • Operating system and version: OSX 12.5.1

Activity

  1. locked and limited conversation to collaborators on Aug 26, 2022
  2. converted this issue into a discussion #1875 on Aug 26, 2022
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions