From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10147 invoked from network); 16 Sep 1998 16:51:11 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 16 Sep 1998 16:51:11 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id MAA09706; Wed, 16 Sep 1998 12:42:18 -0400 (EDT) Resent-Date: Wed, 16 Sep 1998 12:38:30 -0400 (EDT) Message-ID: <19980916114138.A23822@emsphone.com> Date: Wed, 16 Sep 1998 11:41:38 -0500 From: Dan Nelson To: Ken Lareau Cc: zsh-users@math.gatech.edu Subject: Re: /usr/bin/script annoyance References: <19980916110804.A19057@emsphone.com> <199809161631.MAA06749@mailhost2.squonk.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.94.2i In-Reply-To: <199809161631.MAA06749@mailhost2.squonk.net>; from "Ken Lareau" on Wed Sep 16 12:31:07 GMT 1998 X-OS: FreeBSD 2.2.7-STABLE Resent-Message-ID: <"xkMLo1.0.sJ2.6c-_r"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1820 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu In the last episode (Sep 16), Ken Lareau said: >> Oh weird. I just looked at the source to typescript under FreeBSD, >> and it reads in part: >> >> char *shell; >> >> shell = getenv("SHELL"); >> if (shell == NULL) >> shell = _PATH_BSHELL; >> >> execl(shell, "sh", "-i", NULL); >> >> So argv[0] is "sh", and it's entering /bin/sh compatibility mode. >> This is almost _exactly_ the problem Paul Lew reported to the zsh >> list on Aug 11 (mailinglist article archive/latest/4298). Both Bart >> Schaefer and zefram posted ugly workarounds :) > > Hmm... I did a 'truss' on the 'script ' command and dumped it > to a file, and here's what I see when it calls the shell: > > execve("/software/bin/zsh", 0xEFFFF918, 0xEFFFFA60) argc = 2 > > Of course I have no idea what the 2nd and 3rd arguments are to the > execve command, but it would seem to me that it should start up as a > regular zsh shell, no? (Please tell me if I'm missing something > blatently obvious here.) The prototype for the execve syscall is usually execve(const char *path, char *const argv[], char *const envp[]) and the string that determines sh compatibility mode for zsh is not 'path', but 'argv[0]'. If you were to run script under dbx and break on the execve call, I'd bet anything that the contents of the string at 0xEFFFF918 is "sh". Zefram's solution to this problem is the shortest: > Alternatively, set your SHELL to be the executable of this program: > > extern char **environ; > int main(int argc, char **argv) > { > if(argc != 0) > argv[0] = "zsh"; > execve("/usr/local/bin/zsh", argv, environ); > _exit(1); > } That'll guarantee that zsh gets called as "zsh". -Dan Nelson dnelson@emsphone.com