Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!wanginst!vaxine!encore!talcott!harvard!seismo!brl-tgr!tgr!cottrell@NBS-VMS From: cottrell@NBS-VMS Newsgroups: net.unix-wizards Subject: Directory as Prompt String Message-ID: <9389@brl-tgr.ARPA> Date: Wed, 20-Mar-85 18:45:05 EST Article-I.D.: brl-tgr.9389 Posted: Wed Mar 20 18:45:05 1985 Date-Received: Sat, 23-Mar-85 02:29:51 EST Sender: news@brl-tgr.ARPA Lines: 34 /* [ jpage@rruxe.uucp wants to set PS1 in [k]sh when he does 'cd' ] Perhaps this is a good time to repost an earlier article, as I didn't receive as much comment as I liked. The lack of aliases & history in 'sh' is most disturbing. It all started when I read the BSTJ article by Kernighan & Pike (got it right this time!) that bemoaned the multiplicity of options on 'cat', Berkeley 'ls', & then went on to attack the history mechanism of 'csh' as being specific only to 'csh' & not working for ALL input, including programs invoked by [c]sh. After fuming at the authors willingness to trade off useful features for abstract purity, I did some thinking, and came up with the following bizarre ideas. Write a program (prog) which copies its stdin to stdout unless certain escape characters (which implement history, aliases, local cmd editing, anything else you want). Type 'prog | sh -i'. Whenever 'prog' sees the user type 'cd \n' it stuffs ';PS1="`pwd` %' before the '\n'. Thus, the prompt is always the current directory! This will work MOST of the time, but there are exceptions. VI will not work unless its stdin is a tty. Therefore, our prog must intercept any references to VI (or any other uppity interactive program), fork & exec it itself after redirecting stdin back to the tty. There are other things that might be done, such as saving/restoring all stty modes before/after any such interactive program executes, forking the subshell directly from prog, always running in cbreak mode, etc. Please note that this is SYS V we're talking about. No pseudo tty's are available. Now that the cat's out of the bag, let's talk about ways to skin it. What else does 'prog' have to watch out for? jim cottrell@nbs */