Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: How to issue a C SHELL command within a C program Message-ID: <4001@auspex.auspex.com> Date: 2 Sep 90 01:30:54 GMT References: <1990Aug28.214551.6759@gtisqr.uucp> <3985@auspex.auspex.com> <13710@smoke.BRL.MIL> Organization: Auspex Systems, Santa Clara Lines: 26 >Incidentally, while /bin/sh should always be used to execute commands >from a program, when you spawn an interactive subshell you should use >the valuse of the SHELL environment variable. This should also be done if running a *user-supplied* command. Some examples of the rules: 1) if your program is, say, running an "rm -rf" on some directory to remove it, it should use "system()" and do it from "/bin/sh". The program knows what behavior it wants from that command, and doesn't want the user's preferences getting in its way. 2) if the user typed "!" or whatever the "escape to shell" command is, it should use whatever shell SHELL specifies. 3) if the user typed "!egrep mmedea /etc/passwd" or something like that, i.e. a shell escape to run one command, it should use whatever shell SHELL specifies. 4) if the user is telling the program to run some command and grab input from it, or send output to it (for instance, running a region of a file through a filter in an editor), it should use whatever shell SHELL specifies. etc..