Many thanks to Michael for finding the change in sudo behaviour!

For historical accuracy:
On 25/09/2023 20:24, Greg Wooledge wrote:
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.

It must have been a typo.
I should have copy-pasted the command, which was at that point possible, but 
anyway that syntax error no longer appears.

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.

Oops, sorry. With corrected commands it still works, even with default 
"use_pty" in sudoers.

So running in a root shell, the new setting does not interfere. Clearly sudo 
only.

--
John

Reply via email to