From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 367 invoked by alias); 22 Apr 2015 21:26:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34949 Received: (qmail 9039 invoked from network); 22 Apr 2015 21:26:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=RcseCjdv c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=NyToexq47ILYwKjVUTgA:9 a=CjuIK1q_8ugA:10 Date: Wed, 22 Apr 2015 22:26:27 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: Using "source" in a function breaks job control Message-ID: <20150422222627.1f6154e9@ntlworld.com> In-Reply-To: <5537E450.9060205@thequod.de> References: <5537E450.9060205@thequod.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 22 Apr 2015 20:11:28 +0200 Daniel Hahler wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I've noticed that when using "source" (with a file that has at least > one expression) in a function, it will cause job control to not work > as expected anymore. > > TEST CASE: > 1. echo true > /tmp/foo.zsh > 2. vi() { source /tmp/foo.zsh; vim -u NONE -N; } > 3. Run "vi" > 4. In Vim, press Ctrl-Z to put it into the background. > 5. Execute "fg". > > It should bring back "vim", but does not. I'm not going to get any further with this tonight, but using a build to instrument process group handling I posted a few weeks ago it seems that in the failing case the terminal doesn't get reattached to the vim process when the shell function is brought to the foreground. I've omitted irrelevant detail, in particular attaching to the main interactive shell process. In the successful case, +10:11% vi() { vim -u NONE -N; } +10:11% vi Attaching TTY 10 to 20919 [1] + 20922 suspended vi (148)+[1]10:11% ps -fp 20922 UID PID PPID C STIME TTY TIME CMD pws 20922 20794 0 22:11 pts/1 00:00:00 ./zsh +[1]10:12% ps -fp 20919 UID PID PPID C STIME TTY TIME CMD pws 20919 20794 0 22:11 pts/1 00:00:00 vim -u NONE -N +[1]10:12% fg [1] + 20922 continued vi Attaching TTY 10 to 20919 Attaching TTY 10 to 20922 I suspect but haven't checked that final attachtty is after the vim exited successfully (which you can't see happening). In the failing case, +10:12% vi() { . /tmp/foo.zsh; vim -u NONE -N; } +10:13% vi Attaching TTY 10 to 21065 [1] + 21068 running (148)+[1]10:13% ps -fp 21068 UID PID PPID C STIME TTY TIME CMD pws 21068 20794 0 22:13 pts/1 00:00:00 ./zsh +[1]10:13% ps -fp 21065 UID PID PPID C STIME TTY TIME CMD pws 21065 20794 0 22:13 pts/1 00:00:00 vim -u NONE -N +[1]10:13% fg [1] + 21068 continued Attaching TTY 10 to 21068 There's no attachtty to 21065. Handling of SIGCONT within the subshell? pws