9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rc: <{command} and > mess with exit status
@ 2021-06-16  9:17 adr via 9fans
  2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: adr via 9fans @ 2021-06-16  9:17 UTC (permalink / raw)
  To: 9fans

; if(grep a <{echo a}) echo true
a
true

;  if(echo a | grep a >/tmp/1) echo true
true

But now:
; if(grep a <{echo a} >/tmp/1) echo true
;

Is this expected?

Regards,
adr.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-M3c9f2f564a2513558ec2e075
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] rc: <{command} and > mess with exit status
  2021-06-16  9:17 [9fans] rc: <{command} and > mess with exit status adr via 9fans
@ 2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
  2021-06-16 10:42   ` adr via 9fans
  2021-06-16 10:42 ` [9fans] " Anthony Martin
  2021-06-16 14:04 ` [9fans] " ori
  2 siblings, 1 reply; 6+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2021-06-16  9:20 UTC (permalink / raw)
  To: 9fans

; if(grep a <{echo a}) echo true
a
true
; if(echo a | grep a >/tmp/1) echo true
true
; if(grep a <{echo a} >/tmp/1) echo true
true

9front.


------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-M46d9b94091a4e687c6134eb0
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [9fans] Re: rc: <{command} and > mess with exit status
  2021-06-16  9:17 [9fans] rc: <{command} and > mess with exit status adr via 9fans
  2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
@ 2021-06-16 10:42 ` Anthony Martin
  2021-06-16 14:04 ` [9fans] " ori
  2 siblings, 0 replies; 6+ messages in thread
From: Anthony Martin @ 2021-06-16 10:42 UTC (permalink / raw)
  To: 9fans

adr via 9fans <9fans@9fans.net> once said:
> ; if(grep a <{echo a} >/tmp/1) echo true
> ;
>
> Is this expected?

This was fixed a few years ago in 9front:

http://git.9front.org/plan9front/plan9front/2839760066e578e449ebc8b3d71297b9f79a8c99/commit.html

Cheers,
  Anthony

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-M2ee91d7ff496d1af63633dea
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] rc: <{command} and > mess with exit status
  2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
@ 2021-06-16 10:42   ` adr via 9fans
  0 siblings, 0 replies; 6+ messages in thread
From: adr via 9fans @ 2021-06-16 10:42 UTC (permalink / raw)
  To: 9fans

Thanks, it looks like a bug.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-Me2445f0e132fd2e7da654a5e
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] rc: <{command} and > mess with exit status
  2021-06-16  9:17 [9fans] rc: <{command} and > mess with exit status adr via 9fans
  2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
  2021-06-16 10:42 ` [9fans] " Anthony Martin
@ 2021-06-16 14:04 ` ori
  2021-06-16 19:27   ` adr via 9fans
  2 siblings, 1 reply; 6+ messages in thread
From: ori @ 2021-06-16 14:04 UTC (permalink / raw)
  To: 9fans

Quoth adr via 9fans <9fans@9fans.net>:
> ; if(grep a <{echo a}) echo true
> a
> true
> 
> ;  if(echo a | grep a >/tmp/1) echo true
> true
> 
> But now:
> ; if(grep a <{echo a} >/tmp/1) echo true
> ;
> 
> Is this expected?

It's been fixed. Here's the patch:

<git/export 2839760066e578e449ebc8b3d71297b9f79a8c99

From 2839760066e578e449ebc8b3d71297b9f79a8c99
From: cinap_lenrek <cinap_lenrek@felloff.net>
Date: Sat, 08 Sep 2018 12:49:00 +0000
Subject: [PATCH] rc: fix Xpipefd unbalancing the redir stack


Xpipefd wants the pipe descriptor to be closed in turfredir(), so
it pushes the redirection, but this breaks Xpopredir after normal
redirection. so we shuffle the Xpipefd redir to the bottom of the
stack.
---
diff 217e8a06198cf6681fb0c38c26f34d96ae4302f6 2839760066e578e449ebc8b3d71297b9f79a8c99
--- a/sys/src/cmd/rc/exec.c     Mon Sep  3 16:37:45 2018
+++ b/sys/src/cmd/rc/exec.c     Sat Sep  8 08:49:00 2018
@@ -123,6 +123,21 @@
        runq->redir = rp;
 }
 
+void
+shuffleredir(void)
+{
+       redir **rr, *rp;
+
+       rp = runq->redir;
+       if(rp==0)
+               return;
+       runq->redir = rp->next;
+       rp->next = runq->startredir;
+       for(rr = &runq->redir; *rr != rp->next; rr = &((*rr)->next))
+               ;
+       *rr = rp;
+}
+
 var*
 newvar(char *name, var *next)
 {
--- a/sys/src/cmd/rc/fns.h      Mon Sep  3 16:37:45 2018
+++ b/sys/src/cmd/rc/fns.h      Sat Sep  8 08:49:00 2018
@@ -55,6 +55,7 @@
 word*  searchpath(char*);
 void   setstatus(char*);
 void   setvar(char*, word*);
+void   shuffleredir(void);
 void   skipnl(void);
 void   start(code*, int, var*);
 int    truestatus(void);
--- a/sys/src/cmd/rc/havefork.c Mon Sep  3 16:37:45 2018
+++ b/sys/src/cmd/rc/havefork.c Sat Sep  8 08:49:00 2018
@@ -185,7 +185,8 @@
        default:
                addwaitpid(pid);
                close(sidefd);
-               pushredir(ROPEN, mainfd, mainfd);       /* isn't this a noop? */
+               pushredir(ROPEN, mainfd, mainfd);
+               shuffleredir(); /* shuffle redir to bottom of stack for turfredir() */
                strcpy(name, Fdprefix);
                inttoascii(name+strlen(name), mainfd);
                pushword(name);
@{
        bind -ac /dist/plan9front/ /
        git/export 2839760066e578e449ebc8b3d71297b9f79a8c99
}

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-M3410604626038f5a31ffaf9f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] rc: <{command} and > mess with exit status
  2021-06-16 14:04 ` [9fans] " ori
@ 2021-06-16 19:27   ` adr via 9fans
  0 siblings, 0 replies; 6+ messages in thread
From: adr via 9fans @ 2021-06-16 19:27 UTC (permalink / raw)
  To: 9fans

Thanks for the patch!

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tad6cf6b7414c1847-Ma7401221faeb5647bc8bec13
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-16 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  9:17 [9fans] rc: <{command} and > mess with exit status adr via 9fans
2021-06-16  9:20 ` Sigrid Solveig Haflínudóttir
2021-06-16 10:42   ` adr via 9fans
2021-06-16 10:42 ` [9fans] " Anthony Martin
2021-06-16 14:04 ` [9fans] " ori
2021-06-16 19:27   ` adr via 9fans

9fans - fans of the OS Plan 9 from Bell Labs

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9fans

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9fans 9fans/ http://inbox.vuxu.org/9fans \
		9fans@9fans.net
	public-inbox-index 9fans

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9fans


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git