Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] [doc] clone module using xterm's slave mode
- X-seq: zsh-workers 45849
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH] [doc] clone module using xterm's slave mode
- Date: Tue, 19 May 2020 19:54:13 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- In-reply-to: <20200519010140.38c12d2b@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20200517101347.g7v6k2g7hoew636q@chazelas.org> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author