help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange redirection error


From: Christoph Anton Mitterer
Subject: Re: strange redirection error
Date: Mon, 13 Sep 2021 17:24:36 +0200
User-agent: Evolution 3.38.3-1

Hey Greg.

On Sun, 2021-09-12 at 20:13 -0400, Greg Wooledge wrote:
> I don't know what you mean by portable, exactly.  This is help-bash,
> though, so we can initially assume that you are using bash.

Well I meant using only POSIX compatible features, but also working in
bash.
It works in the other shells I've tested, but not in bash (at least not
without that exec) so I figured it would be appropriate to ask the bash
folks why it doesn't work there ;-)


> The way you do this in bash is quite simple:
> 
> #!/bin/bash
> output=$(cmd1 | cmd2)
> exitstatus1=${PIPESTATUS[0]}
> exitstatus2=${PIPESTATUS[1]}
> 
> Easy enough, right?

Sure, but that it would work in bash *only* and no longer in the
others.


> The simplest way to do that is to introduce a temp
> file or two.

That's not an option, a) in my case, where keys are read, one wouldn't
want to write them unnecessarily,... b) the whole system might be still
read only (this code will be run from within an initramfs).




So the questions were really, not for an alternative, but the ones I've
written, and especially why, in bash, I need to do the redirection for
FD 4 with an exec, but not the for FD 3.


Thanks,
Chris.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]