On Mon, Sep 25, 2023 at 01:35:38PM +0900, John Crawley wrote:
> > 4) In a bash shell as root (e.g. "su" or "sudo -s"), do:
> > 
> >     errors=$(apt-get install mirage 2>&1 1>/dev/tty)
> 
> -bash: syntax error near unexpected token `2'
> 
> So bash as root has a problem with the redirection.

At this point I'm guessing you made a typo.  Since you didn't show us
the command you typed, that's my official guess.  Any alternative is
too far beyond belief.

> But this worked OK in the same root shell:
> 
> exec 3>1
> errors=$( apt-get install mirage 2>&1 1>&3 )
> exec 3>&-
> 
> If 'mirage' is replaced with 'mirag' then $errors holds the error message.
> 
> So at least something is working!

Note your typo in the first exec command.  You've got FD 3 redirected
to a file named '1', rather than dup-ing stdout.

> Maybe it is an issue with sudo?

According to Michael's discovery, yes.

Reply via email to