Command line length limit of OS/2 is 32KiB. If the total length of
all arguments is larger than this limit, it's needed to use a
response file.
Previously, the total length calculation was simply to add length of
all arguments. However, this result was not match with real length of
arguments, which are passed to child processes with OS/2 APIs.
Because conversion methods of arguments from libc to OS/2 APIs are
different depending on libc.
For example, kLIBC inserts its signature to an argument list. In
addition, it passes arguments with a leading space like:
arg0
kLIBC signature
arg1
arg2
...
Whereas, EMX just distinguishes arg0 and others like:
arg0
arg1 arg2 arg3 ...
After all, simple sum of a length of arguments are not correct.
The better way is to try to execute a child process, and to retry with
a response file if it fails due to arguments-too-long.
This has been found while doing 'bootstrap', especially 'autoreconf'
in coreutils git repo. It stops with:
autom4te: /usr/local/bin/m4: Invalid argument
From: KO Myung-Hun <komh@chollian.net>
Normal OS/2 programs expect that standard IOs, especially stdin,
are opened in text mode at the startup. By the way, on OS/2 kLIBC
child processes inherit a translation mode of a parent process.
As a result, if stdin is set to binary mode in a parent process,
stdin of child processes is opened in binary mode as well at the
startup. In this case, some programs such as sed suffer from CR.
This is the regression fix of commit 20dbf6.
From: KO Myung-Hun <komh@chollian.net>
‣ also makes the error message nicer:
tg@blau:/usr/obj/bin/mksh $ mksh -n -c '${0$(($(o[))&$(($(p[))&)'
internal error: can't allocate 8388628 data bytes
tg@blau:/usr/obj/bin/mksh $ mksh -n -c '${0$(($(o[))&$(($(p[))&)^J'
mksh: no closing quote
1|tg@blau:/usr/obj/bin/mksh $ ./mksh -n -c '${0$(($(o[))&$(($(p[))&)'
./mksh: syntax error: unmatched '('
1|tg@blau:/usr/obj/bin/mksh $ ./mksh -n -c '${0$(($(o[))&$(($(p[))&)^J'
./mksh: syntax error: unmatched '('
‣ alternative fix would be to keep the block and do…
- } else {
+ } else if (source->type != SEOF) {
… but that would keep “no closing quote” for the case with newline,
and since this seems to not break… nuking unused code is always good ☻
really, getdrvwd should be passed an Xstring (probably with Xinit0 in
the callers), especially as one caller already didn’t update ldestlen
properly… (but not tonight as I’ve really got no head for that left)
instead of parsing extern char **environ; read it from a filesystem
(typical for Plan 9, though this one is __jehanne__ per ifdef)
tested on MirBSD and found to be working
the idea here is that:
- /foo/bar and a:/foo/bar are absolute
- foo/bar is relative
- a:foo/bar needs to be handled specially,
mostly per making it into an absolute (“a:/” + getcwd(a:) + “foo/bar”)
(I just had to use git annotate and look at the two commits from komh
to figure out that the condition in the if is correct here and what
this is supposed to do)
if a path or symlink target is drive-qualified, keep the drive letter
(this part from komh) and, if present, a leading (back)slash (from me)
missing: if a drive qualification is *not* followed by a (back)slash,
we must retrieve the per-drive cwd for the target drive and insert it
just like we insert the cwd for (normal/Unix) relative paths; maybe
consider redoing absolute/relative path logic, DOS paths are tristate
komh’s commit: fix realpath failure on OS/2
On OS/2, an absolute path is 'x:/path/to/file'. Because it has not
a leading slash, '/' is prepended, that is, '/x:/path/to/file'. As a
result, it fails to find a requested file.