@@ -115,32 +115,19 @@ child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "\\-42"`, common.
115115 assert . strictEqual ( stderr , '' ) ;
116116} ) ) ;
117117
118- // Unary-negative eval expressions should not be rejected as missing arguments .
119- child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " -pe -42` , common . mustSucceed ( ( stdout , stderr ) => {
118+ // Eval expressions that start with '-' can be passed with '=' .
119+ child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " --print --eval= -42` , common . mustSucceed ( ( stdout , stderr ) => {
120120 assert . strictEqual ( stdout , '-42\n' ) ;
121121 assert . strictEqual ( stderr , '' ) ;
122122} ) ) ;
123123
124124// Edge case: negative zero should preserve its sign when printed.
125- child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " -pe -0` , common . mustSucceed ( ( stdout , stderr ) => {
125+ child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " --print --eval= -0` , common . mustSucceed ( ( stdout , stderr ) => {
126126 assert . strictEqual ( stdout , '-0\n' ) ;
127127 assert . strictEqual ( stderr , '' ) ;
128128} ) ) ;
129129
130- // Expressions like -NaN should be treated as eval input, not options.
131- child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " -pe -NaN` , common . mustSucceed ( ( stdout , stderr ) => {
132- assert . strictEqual ( stdout , 'NaN\n' ) ;
133- assert . strictEqual ( stderr , '' ) ;
134- } ) ) ;
135-
136- // A bare '-' should be passed to eval and fail with a syntax error.
137- child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " -pe -` , common . mustCall ( ( err , stdout , stderr ) => {
138- assert . notStrictEqual ( err . code , 9 ) ;
139- assert . strictEqual ( stdout , '' ) ;
140- assert . match ( stderr , / S y n t a x E r r o r / ) ;
141- } ) ) ;
142-
143- // Nearby-path safety: option-looking values should still be rejected.
130+ // Nearby-path safety: option-looking values should still be rejected with -e.
144131child . exec ( ...common . escapePOSIXShell `"${ process . execPath } " -e -p` , common . mustCall ( ( err , stdout , stderr ) => {
145132 assert . strictEqual ( err . code , 9 ) ;
146133 assert . strictEqual ( stdout , '' ) ;
0 commit comments