Codeberg/Community
54
325
Fork
You've already forked Community
12

OS/2 REXX code identified as file type Batchfile #2142

Open
opened 2025年09月21日 11:51:26 +02:00 by xynix · 2 comments

Comment

The file type of an uploaded CMD source file is being identified as a "Batchfile", which is wrong in the case of REXX:

https://codeberg.org/xynix/MCD/src/branch/main/MCD.CMD

If the first 2 characters (starting at line 1, column 1) of a CMD file are "/*" (excluding the quotes), then it's not a more common CMD file. It's REXX (or Object REXX) source code.

https://www.os2.kr/komh/os2books/os2tk45/rexxpg/027_L2_Comments.html

As such typically not important for any targetted user at all, but at codeberg.org the perhaps more relevant programming language in use is REXX instead of some batch language.

IBM's definition is slightly different, but a more common CMD file won't start with the magic characters "/*".

No big deal for intended users, but people may be looking for REXX code xor Batchfiles.

### Comment The file type of an uploaded CMD source file is being identified as a "Batchfile", which is wrong in the case of REXX: https://codeberg.org/xynix/MCD/src/branch/main/MCD.CMD If the first 2 characters (starting at line 1, column 1) of a CMD file are "/*" (excluding the quotes), then it's not a more common CMD file. It's REXX (or Object REXX) source code. https://www.os2.kr/komh/os2books/os2tk45/rexxpg/027_L2_Comments.html As such typically not important for any targetted user at all, but at codeberg.org the perhaps more relevant programming language in use is REXX instead of some batch language. IBM's definition is slightly different, but a more common CMD file won't start with the magic characters "/*". No big deal for intended users, but people may be looking for REXX code xor Batchfiles.

It seems that the language detector always recognize .cmd as batchfiles. No mention of REXX.

It seems that the [language detector](https://github.com/go-enry/go-enry/) always recognize `.cmd` as batchfiles. No mention of REXX.
Author
Copy link

It seems that the language detector ... always recognize .cmd as batchfiles. No mention of REXX.

Its GetLanguageByModeline (https://github.com/go-enry/go-enry/tree/master) may be required.

To an user of a REXX app it will hardly matters, but specifically programmers may be looking for REXX code, by using some search filter.

In the case of the IBM operating systems OS/2, eComStation and ArcaOS, *.CMD is used for batchfiles and for REXX code. A comment starting at at line 1, column 1, triggers the executing by CMD.EXE or by REXX.DLL.

IBM, on the same subject, for yet another operating system:

https://www.ibm.com/docs/en/zos/2.4.0?topic=concepts-structure-general-syntax


If you store a REXX exec in a data set that is allocated to SYSPROC, the exec must start with a comment and the comment must contain the characters ""REXX"" within the first line (line 1) of the exec. This is known as the REXX exec identifier and is required in order for the TSO/E EXEC command to distinguish REXX execs from TSO/E CLISTs, which are also stored in SYSPROC.
The characters ""REXX"" must be in the first line (line 1) even if the comment spans multiple lines.
_

You may ignore the last line, about having to use the word REXX in the first line.

Actually the language can be Object REXX too, but I'd restrict it to REXX.

Other REXX interpreters may use own file extensions, so REXX isn't restrcited to *.CMD files.

For example, with Windows and Open Object REXX v3.2.x, I'm executing *.REX files as if such a file is a batchfile. Screenshot added.

Third-party (Object) REXX interpreters may use own file extensions. Like, but not limited to *.RX, *,REX, *.REXX and *.VRX.

With Unixes, there's a trick to mix both. A valid Batchfile, which is also a REXX app. IIRC. Same trick, with a comment.

The utility FILE isn't perfect too. A REXX *.CMD file is an ASCII text file, according to file.

If I restrict it to a programming relatred website and *.CMD files, a (case-insensitive) .CMD file starting with / should be considered to be REXX code.

Or Object REXX code, but both are a member of the REXX family.

As stated earlier, a Batchfiles-status nasicly is no insult (a *.CPP source file is a text file too), but in the case of *.CMD GetLanguageByModeline may have to be used too. It's a Batchfile, unless it starts with a comment. Then it's REXX.

I'd skip checking the full comment, with just /* as the 'shebang'. Starting at line 1, position 1.

You can execute my MCD.CMD with Windows. Then windows will send each line of that Batchfile to CMD.EXE, with many errors. So the other way arround, such a REXX *.CMD file isn't an "Batchfile".

Again: one can refer to a *.CPP source file as a text file, but calling it "C++" would be more perfect. Hence he suggestion to improve the detection, buit I'll accept the wrong label. To a targetted user it won't really matter, but programmers may care. But if you are using Windows and give my MCD.CMD "Batchfile" a try, then you may be disappointed. No big deal, and probably no danger at all.

> It seems that the language detector ... always recognize .cmd as batchfiles. No mention of REXX. Its GetLanguageByModeline (https://github.com/go-enry/go-enry/tree/master) may be required. To an user of a REXX app it will hardly matters, but specifically programmers may be looking for REXX code, by using some search filter. In the case of the IBM operating systems OS/2, eComStation and ArcaOS, *.CMD is used for batchfiles and for REXX code. A comment starting at at line 1, column 1, triggers the executing by CMD.EXE or by REXX.DLL. IBM, on the same subject, for yet another operating system: https://www.ibm.com/docs/en/zos/2.4.0?topic=concepts-structure-general-syntax --- _If you store a REXX exec in a data set that is allocated to SYSPROC, the exec must start with a comment and the comment must contain the characters ""REXX"" within the first line (line 1) of the exec. This is known as the REXX exec identifier and is required in order for the TSO/E EXEC command to distinguish REXX execs from TSO/E CLISTs, which are also stored in SYSPROC. The characters ""REXX"" must be in the first line (line 1) even if the comment spans multiple lines.__ --- You may ignore the last line, about having to use the word REXX in the first line. Actually the language can be Object REXX too, but I'd restrict it to REXX. Other REXX interpreters may use own file extensions, so REXX isn't restrcited to *.CMD files. For example, with Windows and Open Object REXX v3.2.x, I'm executing *.REX files as if such a file is a batchfile. Screenshot added. Third-party (Object) REXX interpreters may use own file extensions. Like, but not limited to *.RX, *,REX, *.REXX and *.VRX. With Unixes, there's a trick to mix both. A valid Batchfile, which is also a REXX app. IIRC. Same trick, with a comment. The utility FILE isn't perfect too. A REXX *.CMD file is an ASCII text file, according to file. If I restrict it to a programming relatred website and *.CMD files, a (case-insensitive) *.CMD file starting with /* should be considered to be REXX code. Or Object REXX code, but both are a member of the REXX family. As stated earlier, a Batchfiles-status nasicly is no insult (a *.CPP source file is a text file too), but in the case of *.CMD GetLanguageByModeline may have to be used too. It's a Batchfile, unless it starts with a comment. Then it's REXX. I'd skip checking the full comment, with just /* as the 'shebang'. Starting at line 1, position 1. You can execute my MCD.CMD with Windows. Then windows will send each line of that Batchfile to CMD.EXE, with many errors. So the other way arround, such a REXX *.CMD file isn't an "Batchfile". Again: one can refer to a *.CPP source file as a text file, but calling it "C++" would be more perfect. Hence he suggestion to improve the detection, buit I'll accept the wrong label. To a targetted user it won't really matter, but programmers may care. But if you are using Windows and give my MCD.CMD "Batchfile" a try, then you may be disappointed. No big deal, and probably no danger at all.
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
accessibility

Reduces accessibility and is thus a "bug" for certain user groups on Codeberg.
bug

Something is not working the way it should. Does not concern outages.
bug
infrastructure

Errors evidently caused by infrastructure malfunctions or outages
Codeberg

This issue involves Codeberg's downstream modifications and settings and/or Codeberg's structures.
contributions welcome

Please join the discussion and consider contributing a PR!
docs

No bug, but an improvement to the docs or UI description will help
duplicate

This issue or pull request already exists
enhancement

New feature
infrastructure

Involves changes to the server setups, use `bug/infrastructure` for infrastructure-related user errors.
legal

An issue directly involving legal compliance
licence / ToS

involving questions about the ToS, especially licencing compliance
please chill
we are volunteers

Please consider editing your posts and remember that there is a human on the other side. We get that you are frustrated, but it's harder for us to help you this way.
public relations

Things related to Codeberg's external communication
question

More information is needed
question
user support

This issue contains a clearly stated problem. However, it is not clear whether we have to fix anything on Codeberg's end, but we're helping them fix it and/or find the cause.
s/Forgejo

Related to Forgejo. Please also check Forgejo's issue tracker.
s/Forgejo/migration

Migration related issues in Forgejo
s/Pages

Issues related to the Codeberg Pages feature
s/Weblate

Issue is related to the Weblate instance at https://translate.codeberg.org
s/Woodpecker

Woodpecker CI related issue
security

involves improvements to the sites security
service

Add a new service to the Codeberg ecosystem (instead of implementing into Gitea)
upstream

An open issue or pull request to an upstream repository to fix this issue (partially or completely) exists (i.e. Gitea, Forgejo, etc.)
wontfix

Codeberg's current set of contributors are not planning to spend time on delegating this issue.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#2142
Reference in a new issue
Codeberg/Community
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?