tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sh(1) exec redirection
> Maybe you remember in the 6th end and before days [...]
I don't. My experience with anything Unixy started with BSD 4.1c, and
that only barely before 4.2 came out.
> This change was made to the NetBSD sh in Jan 2016. It is being
> complained about almost 9 years later. That speaks to large numbers
> of use cases, doesn't it???
Well, I don't _know_ about anyone else's, but in my case, when I
tripped over this misfeature, as I sketched upthread, I didn't mention
it on the lists, or complain about it except privately to coworkers and
in that comment; I just used the workaround I found. (I don't recall
how I found it.)
How many others did likewise? We have no way of knowing. But one
thing history has taught me is that, in something this widely used,
every facility gets used somewhere; indeed, it's not uncommon for bugs
to get so widely depended on that they are elevated to ascended glitch
status and enshrined in future standards. Consider
charset="iso-8859-1" in email.
> The other is that it is far more common for scripts like this to exist
> exec 3<&0 </temporary/stdin
> # many commands that use the alternate stdin
> ....
> # end of those commands (which might be in a loop)
> exec <&3 3<&-
> than it is to have scripts like
> exec 3</some/file
> cmd -f 3 # tell command to use fd 3
Is it? How would anyone know?
> and when deciding which category of commands should need to be
> changed to either set, or clear, the close on exec flag, it seems
> sane to me to pick the ones which are very rare (not many need
> updating) over the ones which are quite common (and created much more
> often) especially as most people don't even consider the issue when
> writing scripts.
I hadn't, until I got bit by it, as I mentioned upthread. I usually
write things like "cmd 0<&3" rather than "cmd 0<&3 3<&-", even. (But
cmd is typically one of mine, or a stock utility, which doesn't mind
having a stray fd open.)
As much as it may be water under the bridge by now, I still think the
correct thing would have been to not break the (unknown number of)
scripts out there that depend(ed) on the old behaviour.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index