[J3] execute_command_line error condition clarification
Eugene Epshteyn
eepshteyn at nvidia.com
Tue Mar 3 14:40:46 UTC 2026
'cat' is a Unix command; I believe Windows equivalent is 'type'. 'cat nofile' is trying to open 'nofile' and dump it to standard output. Since 'nofile' doesn't exist, 'cat' returns status code 1.
I agree that if 'cat' exited due to crash or some other OS signal, that would be a CMDSTAT error. But 'cat nofile' is a regular usage where 'nofile' just happens not to exist, so exit code of 1 seems to be like EXITSTAT error, not CMDSTAT error.
Thank you,
Eugene
________________________________
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of malcolm--- via J3 <j3 at mailman.j3-fortran.org>
Sent: Tuesday, March 3, 2026 9:29 AM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org>
Cc: malcolm at nag-j.co.jp <malcolm at nag-j.co.jp>
Subject: Re: [J3] execute_command_line error condition clarification
External email: Use caution opening links or attachments
Well, I don’t know, is “cat nofile” considered to be an error?
That is an operating system thing, right?
I don’t think that sounds like a CMDSTAT error. Assuming without checking that “cat nofile” returns a non-zero exit status, that is what gets assigned to EXITSTAT not CMDSTAT. Viz it successfully executed “cat” but it returned an error. That’s not an error while trying to execute “cat”.
CMDSTAT would be for some other kind of error, not an exit status non-zero. Maybe that’s what you would get for a command that does not exist. But the whole thing is operating-system-dependent.
Certainly, if the command cannot be executed because the operating system doesn’t support executing commands like that, I would expect CMDSTAT to be set.
Cheers,
--
..................Malcolm Cohen, NAG Oxford/Tokyo.
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Daniel Chen via J3
Sent: Tuesday, March 3, 2026 10:54 PM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org>
Cc: Daniel Chen <cdchen at ca.ibm.com>
Subject: [J3] execute_command_line error condition clarification
Hello,
The standard says the following about the CMDSTAT argument of intrinsic EXECUTE_COMMAND_LINE.
```
CMDSTAT (optional) shall be a scalar of type integer
….
a processor-dependent positive value if an error condition occurs,
…
Otherwise it is assigned the value 0.
```
What is considered as an “error condition” in this context?
Consider the following sample code:
```
integer :: e = 0
integer :: c = 0
call execute_command_line("cat nofile", exitstat=e, cmdstat=c)
print *, e
print *, c
end
```
Should “cat nofile” be considered as an error condition if “nofile” doesn’t exist?
Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20260303/7df7b1d7/attachment-0001.htm>
More information about the J3
mailing list