[J3] execute_command_line error condition clarification
Daniel Chen
cdchen at ca.ibm.com
Tue Mar 3 14:42:14 UTC 2026
Thanks Eugene and Malcolm for the explanation!
Daniel
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of malcolm--- via J3 <j3 at mailman.j3-fortran.org>
Date: Tuesday, March 3, 2026 at 9:31 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: [EXTERNAL] Re: [J3] execute_command_line error condition clarification
This Message Is From an External Sender
This message came from outside your organization.
Report Suspicious<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/AdhS1Rd-!9FFbclcScg9Rf59Tzs6iEZiHmp7Nik7dU8bVej9rf5wxBBWU5iJVs7gLARD9q0ZNTLQJ_xNIHkG7n7DQyfN5MPIa8pE$>
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/f9ecb100/attachment-0001.htm>
More information about the J3
mailing list