Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] using sysread/syswrite with coprocess
- X-seq: zsh-workers 52918
- From: "Anthony Heading" <ajrh@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] using sysread/syswrite with coprocess
- Date: Thu, 09 May 2024 13:09:14 +0000
- Archived-at: <https://zsh.org/workers/52918>
- Feedback-id: i6aa94791:Fastmail
- List-id: <zsh-workers.zsh.org>
Does the patch below make sense? I couldn't see a way to do this otherwise, as it doesn't look like the coprocess fds are exposed by any parameter to enable them to be passed explicitly. I see that using 'p' as a magic integer is supported by 'print' but undocumented, so maybe this style isn't preferred.
diff --git Src/Modules/system.c Src/Modules/system.c
index 929a8b002..e272ff391 100644
--- Src/Modules/system.c
+++ Src/Modules/system.c
@@ -78,14 +78,24 @@ bin_sysread(char *nam, char **args, Options ops, UNUSED(int func))
/* -i: input file descriptor if not stdin */
if (OPT_ISSET(ops, 'i')) {
- infd = getposint(OPT_ARG(ops, 'i'), nam);
+ char *infdarg = OPT_ARG(ops, 'i');
+ if (!strcmp(infdarg, "p")) {
+ infd = coprocin;
+ } else {
+ infd = getposint(infdarg, nam);
+ }
if (infd < 0)
return 1;
}
/* -o: output file descriptor, else store in REPLY */
if (OPT_ISSET(ops, 'o')) {
- outfd = getposint(OPT_ARG(ops, 'o'), nam);
+ char *outfdarg = OPT_ARG(ops, 'o');
+ if (!strcmp(outfdarg, "p")) {
+ outfd = coprocout;
+ } else {
+ outfd = getposint(outfdarg, nam);
+ }
if (outfd < 0)
return 1;
}
@@ -244,7 +254,12 @@ bin_syswrite(char *nam, char **args, Options ops, UNUSED(int func))
/* -o: output file descriptor if not stdout */
if (OPT_ISSET(ops, 'o')) {
- outfd = getposint(OPT_ARG(ops, 'o'), nam);
+ char *outfdarg = OPT_ARG(ops, 'o');
+ if (!strcmp(outfdarg, "p")) {
+ outfd = coprocout;
+ } else {
+ outfd = getposint(outfdarg, nam);
+ }
if (outfd < 0)
return 1;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author