From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22733 invoked from network); 20 Oct 1997 20:25:20 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 20 Oct 1997 20:25:20 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id QAA29890; Mon, 20 Oct 1997 16:18:07 -0400 (EDT) Resent-Date: Mon, 20 Oct 1997 16:18:07 -0400 (EDT) From: Anthony Iano-Fletcher Message-Id: <199710202018.QAA10896@argo.dcrt.nih.gov> Subject: Re: ideas, questions, and bugs To: Zsh-workers@math.gatech.edu Date: Mon, 20 Oct 1997 16:18:59 -0400 (EDT) X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"Y2mrW2.0.zI7.-nxIq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3586 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Hi All, I realise that this might be an old thread by now but I've only just got back after a fortnight's holiday. > > > As much as I try, I can't figure out a good way to have zsh execute some > > > command at startup and stay in interactive mode. > I too have wished for this and have done some strange juggling in .zshrc files to arrange it. However I also have a patch that makes it all simple. Basically you can have a script like: --------------------------------------------- #! /usr/local/bin/zsh -i # create a function which is accessible # for use by the user. foo () { echo bar; } # run some start up command. echo "Welcome!" # modify prompt so its clear where we are. PS1="> $PS1" export PS1 # the user gets control here. source /dev/tty # clean up. echo "Good bye" --------------------------------------------- and this this will give the user a interactive prompt half way through the script after defining some functions, etc.. After the user quits (via exit or ^D) the script continues. The actual change in behaviour only occurs when the file being sourced is a tty. Sourcing a tty is not a common thing to do I guess so the knock on effects are limited. In fact most of the functionality is there anyway. This just triggers the command line editing and the prompt. I had previously asked the list about this feature and the reply at that time was wait a bit for the code to settle down. This patch is simpler than my original and seems to work. Anyway here is a patch against 3.1.2. --------------------------------------------- *** ../zsh-3.0.1/Src/init.c Thu Oct 10 07:05:11 1996 --- ./Src/init.c Thu Dec 19 16:50:41 1996 *************** *** 799,804 **** --- 799,810 ---- dosetopt(SHINSTDIN, 0, 1); scriptname = s; + /* if its a tty we are sourcing then go interactive.....*/ + if (isatty(SHIN)) + { + dosetopt(SHINSTDIN, 1, 1); /* SHINSTDIN option */ + } + sourcelevel++; loop(0); /* loop through the file to be sourced */ sourcelevel--; --------------------------------------------- Anthony.