help-bash
[Top][All Lists]
Advanced

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

Re: Process substitution documentation request


From: Greg Wooledge
Subject: Re: Process substitution documentation request
Date: Wed, 24 Jun 2026 07:22:01 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jun 24, 2026 at 10:27:27 +0200, Borden via wrote:
> Oh dear. Is my writing really that bad? You don't have to answer that. The 
> good and bad news is that this is 100% a sudo problem. I know this because 
> yesterday I ran:
> 
> $ diff <(xxd binaryFile1) <(xxd binaryFile2)
> 
> It worked perfectly the first time. So the bash manual is fine.

You omitted the second half of this, in which you demonstrate that
it *doesn't* work with sudo.  Since I'd never done this, I had to try
it myself, and...

hobbit:~$ a=(6 8 10 2 4) b=(2 4 8)
hobbit:~$ diff <(printf %s\\n "${a[@]}" |sort) <(printf %s\\n "${b[@]}" |sort)
1d0
< 10
4d2
< 6
hobbit:~$ sudo diff <(printf %s\\n "${a[@]}" |sort) <(printf %s\\n "${b[@]}" 
|sort)
[sudo] password for greg: 
diff: /dev/fd/63: No such file or directory
diff: /dev/fd/62: No such file or directory

You're right -- sudo does break this (at least on Linux).  It might
work as expected on platforms where process substitution uses a named
pipe.

Speaking of named pipes, those work fine (with diff!) if they're
explicitly created:

hobbit:~$ mkfifo p1 p2
hobbit:~$ printf %s\\n "${a[@]}" | sort -n > p1 &
[1] 146861
hobbit:~$ printf %s\\n "${b[@]}" | sort -n > p2 &
[2] 146863
hobbit:~$ sudo diff p1 p2
3d2
< 6
5d3
< 10
[1]-  Done                    printf %s\\n "${a[@]}" | sort -n > p1
[2]+  Done                    printf %s\\n "${b[@]}" | sort -n > p2
hobbit:~$ rm p1 p2

I don't know whether this would work with cryptsetup.  If you never
tested cryptsetup with procsubs *without* sudo, then you don't know
either.

If it turns out that cryptsetup luksWhatever --key-file=<(...) works
properly when sudo is removed from the picture, then you can add
"use named pipes" as another idea for how to work around the issue.



reply via email to

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