[J3] execute_command_line error condition clarification

Eugene Epshteyn eepshteyn at nvidia.com
Tue Mar 3 14:26:23 UTC 2026


Just to add my thoughts:

'cat nofile' returns status code of 1 if 'nofile' doesn't exist. I think that execute_command_line("cat nofile", exitstat=e, cmdstat=c) should result in exitstat=1 and cmdstat=0, because it fulfilled user's request and successfully executed 'cat'. The fact that 'cat' returned status 1 is not an error from execute_command_line() point of view, it's some code specific to 'cat' and is covered by exitstat.

Would like to hear committee's opinion on this matter.

Thanks,
Eugene
________________________________
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Daniel Chen via J3 <j3 at mailman.j3-fortran.org>
Sent: Tuesday, March 3, 2026 8:54 AM
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

External email: Use caution opening links or attachments

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/253d53bd/attachment-0001.htm>


More information about the J3 mailing list