Sujet : Re: Running an editor from ANSI C
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.cDate : 08. Jun 2024, 12:07:10
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v41e0u$2j12l$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Mozilla Thunderbird
On 08/06/2024 01:36, Kaz Kylheku wrote:
On 2024-06-07, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
On 07/06/2024 21:04, Scott Lurndal wrote:
How does your pure "C" shell
spawn a new process without using posix or other OS-specific
APIs?
>
It can call "system".
1. System is an interface to someone else's existing shell1
2. To do process coordination using "system", you will have to
rely on implementation-specific syntax, like POSIX.
For instance system("command1 | command2 > file").
As soon as you rely on any specific command syntax in
system(), your program is no longer maximally portable ISO C;
it is a mixed-language program.
3. A conforming C implementation need not provide a command
interpreter, in which case system(NULL) returns zero.
Yes but all I do is I have a command called "system". The user types
"system ls" at the BBX$ prompt, and it calls system("ls"); So it's a very simple way of letting the shell run programs on the host computer. Of course if it is running on DOS the "ls" won't work and the user must type "system dir" to get his desired result. But he's the user, he knows that.
And all you need is "export", "system" and "import". Export a file. Run system to do whatever you want with it, import it, and if you like call system agin to delete it. And effectively it's a minimal shell with complete power.
-- Check out Basic Algorithms and my other books:https://www.lulu.com/spotlight/bgy1mm