-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
On yargs@16.2.0 I discovered a bug causing the application to crash unexpectedly if one of the values in the arguments array provided to the yargs function is exactly ---- (i.e., 4 hyphens). As far as I can tell any other number of hyphens works fine, I did not test any other version of yargs. The error produced by this input can be found below and it is thrown (if I'm not mistaken) by this snippet of code:
Lines 1757 to 1760 in 31765cb
| self._copyDoubleDash = function (argv: Arguments): any { | |
| if (!argv._ || !argv['--']) return argv; | |
| // eslint-disable-next-line prefer-spread | |
| argv._.push.apply(argv._, argv['--']); |
I'm not exactly sure what goes wrong but it seems to me that argv['--'] is internally used for something, and by using the argument value ---- this value is changed unexpectedly resulting in the error.
.../node_modules/yargs/build/index.cjs:2794
argv._.push.apply(argv._, argv['--']);
^
TypeError: CreateListFromArrayLike called on non-object
at Object.Yargs.self._copyDoubleDash (.../node_modules/yargs/build/index.cjs:2794:21)
at Object.Yargs.self._postProcess (.../node_modules/yargs/build/index.cjs:2782:25)
at Object.parseArgs [as _parseArgs] (.../node_modules/yargs/build/index.cjs:2774:21)
at Object.get [as argv] (.../node_modules/yargs/build/index.cjs:2651:25)
at Object.<anonymous> (.../src/index.ts:41:5)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Module.m._compile (/home/eric/.nvm/versions/node/v12.16.0/lib/node_modules/ts-node/src/index.ts:1056:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Object.require.extensions.<computed> [as .ts] (/home/eric/.nvm/versions/node/v12.16.0/lib/node_modules/ts-node/src/index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:1001:32)
EDIT: it seems that appending whitespace characters (e.g. \r or \n) or = and than other non-space character to ---- will still result in the same error.