From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: Using "source" in a function breaks job control
Date: Wed, 22 Apr 2015 21:41:55 +0100 [thread overview]
Message-ID: <20150422214155.67ece429@ntlworld.com> (raw)
In-Reply-To: <5537E450.9060205@thequod.de>
On Wed, 22 Apr 2015 20:11:28 +0200
Daniel Hahler <genml+zsh-workers@thequod.de> 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.
This may take some tracking down, but I suspect the "source" is
doing something to the current shell status that it's then not undoing.
> The PID 23415 refers to a "zsh" subprocess:
>
> | |-zsh,23316
> | | |-vim,23414 -u NONE -N
> | | `-zsh,23415
>
> Is this behavior expected?
> Why is there a new subprocess being created?
That bit's correct. What you're suspending is the shell function, to do
which it has to fork a shell. Try suspending and then foregrounding:
vi() {
vim
print "vim exited with status $?"
}
and you'll see that the last line would be executed in the wrong place
or not at all without that. Unfortunately it seems to get the status
wrong: it's the one from when vim suspended rather than when it exited.
pws
next prev parent reply other threads:[~2015-04-22 20:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-22 18:11 Daniel Hahler
2015-04-22 20:41 ` Peter Stephenson [this message]
2015-04-22 21:26 ` Peter Stephenson
2015-04-23 4:55 ` Bart Schaefer
2015-04-23 20:13 ` Peter Stephenson
2015-04-24 6:22 ` Bart Schaefer
2015-04-24 15:25 ` Peter Stephenson
2015-04-24 15:43 ` Peter Stephenson
2015-04-24 16:21 ` Bart Schaefer
2015-04-27 17:29 ` Peter Stephenson
2015-04-28 10:18 ` Peter Stephenson
2015-04-28 15:57 ` Bart Schaefer
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=20150422214155.67ece429@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/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).