Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mcgill-vision.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!cmcl2!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: net.lang.c Subject: Re: setenv from c Message-ID: <158@mcgill-vision.UUCP> Date: Wed, 9-Oct-85 03:24:35 EDT Article-I.D.: mcgill-v.158 Posted: Wed Oct 9 03:24:35 1985 Date-Received: Sat, 12-Oct-85 16:24:59 EDT References: <2936@ncsu.UUCP> <6000007@mirror.UUCP> <1355@teddy.UUCP>, <337@ihdev.UUCP> Organization: McGill University, Montreal Lines: 52 > >> Is it possible to set a csh environment variable within a C program? > > > >In all the replies to this question, I have not yet seen my favorite techniqe. > >This only works on BSD 4.X (at least as far as I know). There is an > >undocumented ioctl() which allows you to push data back onto your input queue > >(i.e. simulate characters typed at the terminal). Using this technique, one > >can stuff strings like "setenv TERM xxx\n" into the parent shell's input. > > [[[ code using TIOCSTI omitted ]]] > > Undocumented? TTY(4) page 12 (66lines/page). This call does not exist > on either System 5 or Version 7 - however the hack to put them into the > kernel is about twenty lines. Oh for this and FIONREAD to be put into > standard SYS V!!! How right you are. TIOCSTI is one of the neatest features around. (Maybe not heavily used, but neat.) However, I must take issue with > > Using this technique, one can stuff strings like "setenv TERM xxx\n" > > into the parent shell's input. You can't, in general. All you can do is stuff stuff back into the terminal input stream, which is not always the shell's input stream (shell scripts etc). Besides, guess what it can do to typeahead: login: mouse Password: Last login etc.... /etc/motd etc.... cd foo em % % setenv TEaRM xxx emsetenv: Command not found. % cs test.c cs: Command not found. Well, maybe I notice in time not to hit the last newline. Besides, that isn't what it looks like because I hacked upon my shell to give supersmart line editing (and I don't use "%" for my prompt). Tsk tsk. Please try to be more precise in the future. -- der Mouse {ihnp4,decvax,akgua,etc}!utcsri!mcgill-vision!mouse philabs!micomvax!musocs!mcgill-vision!mouse Hacker: One responsible for destroying / Wizard: One responsible for recovering it afterward