5 ms·
Worth noting that POSIX sh only specifies that file descriptors up to 9 be supported, and many shells stick with this minimum.
by pxeger1 3y ago
Worth noting that POSIX sh only specifies that file descriptors up to 9 be supported, and many shells stick with this minimum.
- junon 3y agoMaximum, you mean? Or am I misunderstanding you? Written a lot of shell scripts in my days and somehow this fact escaped me. Thanks!
- js2 3y agoRephrased for clarity: POSIX specifies at least (a minimum of) 9. POSIX does not specify a maximum. Shells may provide more than 9. From the spec: > Open files are represented by decimal numbers starting with zero. The largest possible value is implementation-defined; however, all implementations shall support at least 0 to 9, inclusive, for use by the application. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... And from the bash manual: > Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally. https://www.gnu.org/software/bash/manual/bash.html#Redirections https://www.gnu.org/software/bash/manual/bash.html#Redirecti... Despite writing shell scripts for nearly three decades, I also was unaware of what POSIX had to say but I can't recall ever needing more than a couple extra FDs at most.
- junon 3y agoAh, thanks! Makes more sense :)