Mail Archives: djgpp-workers/1997/09/10/04:51:36
On Tue, 9 Sep 1997, Molnar Laszlo wrote:
> I think it's dangerous using system() to call builtin shell
> commands.
But that's what ANSI C requires! It says (in para 7.10.4.5) that
`system' passes its argument ``to the host environment to be executed
by a COMMAND PROCESSOR''. So we cannot disable this behavior.
Also, DOS users are accustomed to that, and `system' does a fairly
good job when they do. Other DOS compilers *always* call COMMAND.COM
inside their `system', so people are used to say things like
``system("dir > dir.lst")'' and expect that to work.
> Yes, but the perl doc says, that system() won't call the shell if not
> needed.
The docs can say that the DOS version behaves differently.
> And I already received a report from a guy, who patched my perl
> binary(!) to use 4dos instead of sh.exe :)
That's why I think `system' should be left alone, so it calls whatever
shell the user prefers.
> There is a
> script in the perl distribution called 'perldoc' to view the
> documentation. It tries to call several pagers (first 'less', then
> 'more'). If the user doesn't have less and doesn't set SHELL to bash, he
> can't use it, because the script tries to call 'less filename.something'
> and won't notice that the call failed, because of command.com. So the
> user won't see the documentation :(
Change that to "less.exe", "more.exe", etc. and it will work even with
COMMAND.COM. I don't think a single script is a reason enough to make
such a crucial change in `system'.
> What do you think about a new flag instead of __system_emulate_command?
> If someone knows what he is doing... (or thinks he knows :)
What would this flag do?
> Why not if he uses another shell's builtin command? If someone wants to
> use a builtin, he must call the shell directly. It's quite normal, isn't
> it?
This is correct only for `spawn' and `exec' families of functions.
ANSI requires that `system' should know how to run any command that
the command processor (i.e., the shell) understands.
- Raw text -