zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: zpty woes
Date: Thu, 15 May 2008 16:44:46 +0100	[thread overview]
Message-ID: <20080515164446.4971b8de@news01> (raw)
In-Reply-To: <20080515132609.GB5190@sc.homeunix.net>

On Thu, 15 May 2008 14:26:09 +0100
Stephane Chazelas <Stephane_Chazelas@yahoo.fr> wrote:
> "+myscript:1> scp hello...."
> 
> (by, the way, shouldn't it be something like "+(zpty):1> scp
> hello"?)

zpty currently exec's code directly, it doesn't go through eval.  Borrowing
the code from eval should fix this.  There may be other
parse_string()/execode() pairs that need this.  This is crying out to be
object-orientated...

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.194
diff -u -r1.194 builtin.c
--- Src/builtin.c	14 May 2008 10:48:28 -0000	1.194
+++ Src/builtin.c	15 May 2008 15:42:33 -0000
@@ -4681,7 +4681,7 @@
 /* eval: simple evaluation */
 
 /**/
-int ineval;
+mod_export int ineval;
 
 /**/
 int
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.190
diff -u -r1.190 utils.c
--- Src/utils.c	14 May 2008 10:48:28 -0000	1.190
+++ Src/utils.c	15 May 2008 15:42:37 -0000
@@ -33,7 +33,7 @@
 /* name of script being sourced */
 
 /**/
-char *scriptname;
+mod_export char *scriptname;
 
 #ifdef MULTIBYTE_SUPPORT
 struct widechar_array {
Index: Src/Modules/zpty.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v
retrieving revision 1.37
diff -u -r1.37 zpty.c
--- Src/Modules/zpty.c	25 Jan 2008 16:48:24 -0000	1.37
+++ Src/Modules/zpty.c	15 May 2008 15:42:37 -0000
@@ -290,22 +290,34 @@
 newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
 {
     Ptycmd p;
-    int master, slave, pid;
+    int master, slave, pid, oineval = ineval;
+    char *oscriptname = scriptname;
     Eprog prog;
 
+    /* code borrowed from bin_eval() */
+    ineval = !isset(EVALLINENO);
+    if (!ineval)
+	scriptname = "(zpty)";
+
     prog = parse_string(zjoin(args, ' ', 1));
     if (!prog) {
 	errflag = 0;
+	scriptname = oscriptname;
+	ineval = oineval;
 	return 1;
     }
 
     if (get_pty(1, &master)) {
 	zwarnnam(nam, "can't open pseudo terminal: %e", errno);
+	scriptname = oscriptname;
+	ineval = oineval;
 	return 1;
     }
     if ((pid = fork()) == -1) {
 	zwarnnam(nam, "can't create pty command %s: %e", pname, errno);
 	close(master);
+	scriptname = oscriptname;
+	ineval = oineval;
 	return 1;
     } else if (!pid) {
 	/* This code copied from the clone module, except for getting *
@@ -406,6 +418,8 @@
     if (nblock)
 	ptynonblock(master);
 
+    scriptname = oscriptname;
+    ineval = oineval;
     return 0;
 }
 

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


      reply	other threads:[~2008-05-15 15:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 12:02 Jaime Vargas
2008-05-15 13:10 ` Stephane Chazelas
2008-05-15 13:18 ` Peter Stephenson
2008-05-15 14:50   ` Stephane Chazelas
2008-05-15 15:26     ` Peter Stephenson
2008-05-15 16:25     ` Jaime Vargas
2008-05-15 16:36       ` * " Peter Stephenson
     [not found]     ` <99E8D43E-EC34-48DB-A5AD-BFA197A3AAA3@mac.com>
2008-05-15 17:03       ` Stephane Chazelas
     [not found]       ` <480CEB80051F27AE@mac.com>
2008-05-15 17:38         ` Jaime Vargas
2008-05-15 17:53           ` Jaime Vargas
2008-05-20  3:25             ` Jaime Vargas
2008-05-20 14:28               ` zpty woes (enhancement request) Jaime Vargas
2008-05-20 16:25                 ` Bart Schaefer
2008-05-15 13:26 ` zpty woes Stephane Chazelas
2008-05-15 15:44   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515164446.4971b8de@news01 \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).