From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12368 invoked by alias); 21 Jan 2013 03:58:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17596 Received: (qmail 28729 invoked from network); 21 Jan 2013 03:58:40 -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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=mesmtp; bh= Qpemp+tdmPcupI6GrbTj29dQwmg=; b=MKK3ELwy8tnzPeoerTvIE9K7e82q2Dy5 Lm6eGIMsS46708ZxM3Cz81WTy1bBQu6qY2G0wR4OXOu5buv605DYIvz9gVPxlKfk 8XHMhFJgqnZxAwUzNoSmCprI8jaOvTRvq6qcLh+C6keOtaEoh+wshdTN85WgITti 0v8ENjQABpc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=smtpout; bh=Qpemp+tdmPcupI6GrbTj29dQwmg=; b=iUlzEazHNwUAHxbmkoAPfzTpkf0z Aq54cVW8y5QVwyKi/6PMgn68J/oWsFsjkax3bGXvPjvJfUsbtCl6vtxfLSYV1bxI Ronp5BL107DaBdO1kcd/moiGNCYK91Ux6c1P8dqnLxMyZF+0s6QCSPONBiXWk3vZ OSgjbLCc/4ukwOM= X-Sasl-enc: PFq9cVgc1c+if0s0dp2XSM4Y1oTknPz8ey3pKQzkh/LX 1358740710 Date: Mon, 21 Jan 2013 05:58:26 +0200 From: Daniel Shahaf To: Bart Schaefer Cc: zsh-users@zsh.org Subject: Re: Backgrounding part of 'ssh-agent $cmd' Message-ID: <20130121035826.GC2968@lp-shahaf.local> References: <20130116065951.GA2992@lp-shahaf.local> <130116093514.ZM19656@torch.brasslantern.com> <20130118061845.GC3024@lp-shahaf.local> <130117232602.ZM23841@torch.brasslantern.com> <20130118141322.GE4666@lp-shahaf.local> <130118073522.ZM24670@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <130118073522.ZM24670@torch.brasslantern.com> User-Agent: Mutt/1.5.18 (2008-05-17) Bart Schaefer wrote on Fri, Jan 18, 2013 at 07:35:22 -0800: > On Jan 18, 4:13pm, Daniel Shahaf wrote: > > > > The part that I find less than ideal so far is that, under load, the GUI > > ssh-askpass dialog appears after foo_main has started. > > You could do it like this: > > ( # Subshell so caller's environment won't be changed; could instead > # declare locals, but this is immune to changes in ssh-agent > eval `ssh-agent` > ssh-add ~/.ssh/foo.id_rsa > { > for h in host1 host2 host3; do > ssh -MNf $h & > done > wait > } always { > ssh-agent -k > } & > ) > > Then you don't have to background foo_ssh_preseed, and your preferred > order of events is retained. Thanks! This makes the ssh prompt textual again, while keeping the loop backgrounded; that's perfect. To summarise, now I have: foo_ssh_preseed() { if [ -S ~/.ssh/ControlPath/host1 ] then return fi zsh -fc ' # Subshell so caller"s environment won"t be changed; could instead # declare locals, but this is immune to changes in ssh-agent eval `ssh-agent | tee /dev/stderr` ssh-add ~/.ssh/foo.id_rsa { for h in \ host1 host2 host3 \ ; do ssh -MNf $h & done wait } always { ssh-agent -k } & ' } Which relies on ControlPath,ServerAliveInterval,IdentityFile being set in ~/.ssh/config. I also had the subshell use -f --- mainly because I didn't know of anything else in my configuration would interfere with the always{} block, but upon review I notice it has the side-effect of making the enclosing function a valid /bin/sh function. Thanks again. Daniel