[J3] execute_command_line error condition clarification

malcolm at nag-j.co.jp malcolm at nag-j.co.jp
Tue Mar 3 14:29:10 UTC 2026


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/351836a9/attachment.htm>


More information about the J3 mailing list