From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24168 invoked from network); 19 May 2020 18:55:07 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 19 May 2020 18:55:07 -0000 Received: (qmail 6308 invoked by alias); 19 May 2020 18:54:59 -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: List-Unsubscribe: X-Seq: 45849 Received: (qmail 6917 invoked by uid 1010); 19 May 2020 18:54:59 -0000 X-Qmail-Scanner-Diagnostics: from relay7-d.mail.gandi.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25814. spamassassin: 3.4.4. Clear:RC:0(217.70.183.200):SA:0(-2.6/5.0):. Processed in 4.062765 secs); 19 May 2020 18:54:59 -0000 X-Envelope-From: stephane@chazelas.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _nblcust.gandi.net designates 217.70.183.200 as permitted sender) X-Originating-IP: 94.3.152.49 Date: Tue, 19 May 2020 19:54:13 +0100 From: Stephane Chazelas To: Daniel Shahaf Cc: Zsh hackers list Subject: Re: [PATCH] [doc] clone module using xterm's slave mode Message-ID: <20200519185413.m54ljmsvv2zrmwww@chazelas.org> Mail-Followup-To: Daniel Shahaf , Zsh hackers list References: <20200517101347.g7v6k2g7hoew636q@chazelas.org> <20200519010140.38c12d2b@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200519010140.38c12d2b@tarpaulin.shahaf.local2> 2020-05-19 01:01:40 +0000, Daniel Shahaf: [...] > There's a race condition here («clone» might run before «./pty» is > created). Is it worthwhile to point it out in the text, or add > a «sleep» in the example? [...] You're right, maybe a better approach would be to supply a contrib function for that which could be extended to other terminal emulators like: clone_on_new_terminal() { local terminal_cmd setup case $1 in (*xterm*) terminal_cmd="$1 -Sunused/3" setup='IFS= read -r WINDOWID' ;; (*rxvt*) terminal_cmd="$1 -pty-fd 3" setup= ;; (*) printf >&2 '"%s" terminal not supported\n' "$1" return 1 ;; esac socat -d -d PTY,wait-slave,echo=0 "exec:$terminal_cmd,nofork,fdout=3,fdin=3" 2>&1 | { local -a fields IFS=' ' read -rA fields clone $fields[-1] if (($!)); then cat >&2 else eval "$setup" fi } } Still a bit brittle as it relies on a specific output format of socat's debug output. > By the way, WDYT of adding a concept index entry (e.g., «cindex(tty, > cloning the shell onto an unused)») at the top of the file? I think the > existing cindex entries won't help someone who doesn't know what the > module is called to discover it. [...] To be honest, I'm not sure I understand what that module is for. What would be a typical use case? -- Stephane