Author Topic: Max. line length for calling utilities from a .cmd file  (Read 8298 times)

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Max. line length for calling utilities from a .cmd file
« on: July 07, 2020, 10:33:00 pm »
I noted down that the max. input length for cmd.exe is 299.

Does the same limit also apply for calls from a .cmd file of e.g. grep.exe?

(I have several dir specs for grep and I wanted to avoid to split that into multiple grep calls. The -f option for search patterns from a file will already be used.)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5088
  • Karma: +117/-1
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #1 on: July 08, 2020, 02:56:23 am »
I think so. What I did when coming across that limit was create a sh file and use sh.exe to call it. maximum length seems to be at least 40K, at least a 39871 byte file works while a 56kB file failed and had to be split into a response file.
Grep might also be linked with -Zresp in which case another option is a response file.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #2 on: July 09, 2020, 12:56:26 am »
Thanks Dave. That saves me some time. I'm aware about the sh option, but that would be another prerequisite beside grep. Your calls to compile a Mozilla app probably afford a shell with a much larger limit since a long time.

It's all about calling grep from EPM for the next release. Let's see what will be the best and fastest solution. BTW: grep.exe is about 10 times faster than doing similar in EPM's macro language E. That's why calling an external utility is a preferred option in this case.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5088
  • Karma: +117/-1
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #3 on: July 09, 2020, 05:19:15 am »
Actually, the call to link xul.dll is a new thing caused by the new GCC not properly handling response files, have to feed emxomfld a long command line.
As for prerequisites, it seems most everyone should have sh.exe installed now as part of YUM/RPM.

Andi B.

  • Hero Member
  • *****
  • Posts: 870
  • Karma: +14/-2
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #4 on: July 09, 2020, 08:58:39 am »
If it is of any help I think current 4os2 command line length limit is 2k. Years ago I expanded this for Elbert who needs this to compile some QT stuff.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #5 on: July 09, 2020, 09:12:37 pm »
Thanks. I have now several options.

One slower fallback method already exists: Search with E code, so some options can be implemented later. (It's fast enough for searching in included files only, but not for searching in dirs and filemasks.)

Dave, you're probably right with the availability of grep.exe and sh.exe. Times have changed.

Andi, I didn't know that about 4os2.

Martin Vieregg

  • Sr. Member
  • ****
  • Posts: 278
  • Karma: +2/-0
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #6 on: July 10, 2020, 10:02:55 pm »
You can write a cmd file. The limit of a single commands in a cmd file seems to be 1023 characters.

The limit when typing a command in cmd.exe is 259 characters. It seems to be syntax specific. A longer input shows an error message:

SYS1065: The input line is too long.

In MeShell, there is a limit of 255 characters because of a bug. It will be fixed in the next version 0.71. Then the combination of MeShell and 4os2 will work with longer lines. Together with cmd.exe, you will have a limit of 259 characters again.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 827
  • Karma: +14/-0
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #7 on: July 10, 2020, 10:35:25 pm »
Thanks Martin. I was too lazy to try it out. I've tried it now for a .cmd file and got the same limit as you. 1023 should suffice for most grep dir specs I plan to use. That makes it easier.

The other value, 259, makes sense, because of _MAX_PATH = 260.
« Last Edit: July 11, 2020, 12:04:18 am by Andreas Schnellbacher »

Martin Vieregg

  • Sr. Member
  • ****
  • Posts: 278
  • Karma: +2/-0
    • View Profile
Re: Max. line length for calling utilities from a .cmd file
« Reply #8 on: July 11, 2020, 11:24:24 am »
I have updated MeShell to 0.71. Not tried it yet, but with 4os2 now the command length limit should be 2048 characters.
Here you can download MeShell 0.71 (700 kB)