On Thu, Jun 18, 2026 at 22:02:54 +0200, Borden via wrote:
> > Your issue is that the crypsetup program *specifically* expects its keyfile
> > arguments to be regular files, not pipes.
>
> That's helpful, and I've already given the cryptsetup people some feedback
> that
> their vocabulary doesn't match the dictionary definitions of the words - or
> even uses in other programs. I'm satisfied that I can't do what I want if I at
> least understand why I can't do that. Per the Process Substitution language:
>
> "its input or output appears as a filename. This filename is passed as an
> argument to the current command as the result of the expansion."
>
> So, if what you're saying is correct, I don't think I'm completely
> unreasonable
> in believing that I could swap a pipe name into a filename field (AKA
> everything in Unix is a file). Lots of other people on the Internet (and
> there's no point calling them out) describe named pipes and file handlers as
> largely interchangeable.
A filename can refer to a regular file, or a directory, or a named pipe,
or a character or block device, or a socket, etc. In the case of <()
process substitutions, the filename that's created by bash will either
be a named pipe, or a /dev/fd/* reference to an anonymous pipe, depending
on the platform.
In most cases, you can use these process substitution filenames in place
of regular files. For example, GNU diff has no problems with them:
hobbit:~$ a=(2 8 6 4 12) b=(6 8 2)
hobbit:~$ diff <(printf %s\\n "${a[@]}" |sort) <(printf %s\\n "${b[@]}" |sort)
1d0
< 12
3d1
< 4
But cryptsetup luksWhatever --key-file and --new-keyfile apparently has
a problem with them.
OpenSSH's ssh -i option also has a problem with them:
hobbit:~$ ssh -i ~/.ssh/id_rsa remote date
Thu Jun 18 19:23:58 EDT 2026
hobbit:~$ ssh -i <(cat ~/.ssh/id_rsa) remote date
Warning: Identity file /dev/fd/63 not accessible: No such file or directory.
Thu Jun 18 19:24:04 EDT 2026
It wants regular files, just like cryptsetup does. I've seen a few people
run into that problem before, which is why your very similar problem
with cryptsetup didn't shock me.
> I think you're onto something there. I can't dump the unencrypted file into a
> variable because the binary has several null characters in the file which, I
> understand, breaks bash parsing.
You're correct that you can't store NUL bytes in bash variables. It's
not because of "parsing", though. It's because bash variables contain
C-style strings, where a NUL byte ends the string.
> > 1) A PSA seeking better documentation for the good of the community
>
> That's what I aim for when I write a mailing list. I know that I'm expected to
> use every other resource that I can before asking. I try to explain why and
> how
> the documentation and other resources made me think that the software runs a
> certain way. If the documentation can't be any clearer and I'm just stupid,
> so be
> it.
>
> It's also why I ask questions abstractly - nobody cares about my problems, so
> I
> try to ask more generally about how the software works rather than whatever
> specific use I'm trying to apply (unless asked).
The nature of shell scripts is that we *do* need to care about your
problem, because every shell script is unique, and in many cases, you're
writing the script to work around something that's broken, incomplete
or inconvenient.
With any nontrivial question, we'll need all the details in order to give
a useful answer, especially the nature of the problem you're dealing with.
> As I mentioned, the
> documentation as it stands led me to believe that the software works a certain
> way and the results don't match my expectations.
You were using the process substitution feature correctly. It just didn't
work because the program you were using it *with* has undocumented
restrictions.
So yes, there's a need to improve the documentation, but in this case
it's cryptsetup's documentation, not bash's, that needs improvement.
P.S. Whoever named those --key-file and --new-keyfile options should have
made their spelling consistent. Either "keyfile" or "key-file". Make up
your mind.