Re: ${ ...; } can end up closing user fds open within

Chet Ramey <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Organization ITS, Case Western Reserve University
Message-ID <[email protected]>
On 1/23/26 4:37 AM, Stephane Chazelas wrote:

> Bash Version: 5.3
> Patch Level: 3
> Release Status: release
> 
> (same in current "devel" git head (commit
> c4b56ed9ac00424bde0f9ce3adfb7edb3d19a557)
> 
> Description:
> 
> $ bash -c 'echo "${ exec 4> /dev/null && echo OK; }"; ls -dog "/proc/$$/fd/4"'
> OK
> l-wx------ 1 64 Jan 23 09:22 /proc/19083/fd/4 -> /dev/null
> 
> fine, but when 4 is the first free fd like after:
> 
> $ exec 3>&1
> $ bash -c 'echo "${ exec 4> /dev/null && echo OK; }"; ls -dog "/proc/$$/fd/4"'
> 
> ls: cannot access '/proc/19106/fd/4': No such file or directory

Thanks for the report. It's an easy fix.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc (application/pgp-signature, 203 B)
-----BEGIN PGP SIGNATURE-----

wmMEABEIACMWIQR8ATX7CIqvbGbGULm7WGnwZOp0qwUCaXOQygUDAAAAAAAKCRC7WGnwZOp0q9Ej
AJkBo683fhowF1jJGkTiNo6b9fR63wCfQGKtarNPqx9PQQs3yu62AFa+Be4=
=G/Pz
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.