Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: "exit 1" and "exit(1)" are apparently not the same

by ikegami (Patriarch)
on Nov 20, 2023 at 16:57 UTC ( [id://11155721] : note . print w/replies, xml ) Need Help??


in reply to "exit 1" and "exit(1)" are apparently not the same

I can't find any documentation that explains this differing behaviour.

This is the documentation for exit (as produced by help exit):

Quits the CMD.EXE program (command interpreter) or the current batch script. EXIT [/B] [exitCode] /B specifies to exit the current batch script instead of CMD.EXE. If executed from outside a batch script, it will quit CMD.EXE exitCode specifies a numeric number. if /B is specified, sets ERRORLEVEL that number. If quitting CMD.EXE, sets the p +rocess exit code with that number.

The bevahiour of exit(1) isn't defined, and there's no reason to believe it's valid. (It's no like you can do echo(foo) or perl(file.pl), and exit(1) is no different.) You provided garbage, and received garbage in return (GIGO).