[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf -u "$fd"?
From: |
Kerin Millar |
Subject: |
Re: printf -u "$fd"? |
Date: |
Sun, 19 May 2024 19:11:36 +0100 |
User-agent: |
Cyrus-JMAP/3.11.0-alpha0-456-gcd147058c-fm-hotfix-20240509.001-g0aad06e4 |
On Sun, 19 May 2024, at 5:08 PM, alex xmb sw ratchev wrote:
> On Sat, May 18, 2024, 04:54 Zachary Santer <zsanter@gmail.com> wrote:
>
>> Was «difference between read -u fd and read <&"$fd"» on help-bash@gnu.org
>>
>> On Thu, May 16, 2024 at 12:51 AM Kerin Millar <kfm@plushkava.net> wrote:
>> >
>> > On Thu, 16 May 2024, at 3:25 AM, Peng Yu wrote:
>> > > Hi,
>> > >
>> > > It appears to me that read -u fd and read <&"$fd" achieve the same
>> > > result. But I may miss corner cases when they may be different.
>> > >
>> > > Is it true that they are exactly the same?
>> >
>> > They are not exactly the same. To write read -u fd is to instruct the
>> read builtin to read directly from the specified file descriptor. To write
>> read <&"$fd" entails one invocation of the dup2 syscall to duplicate the
>> specified file descriptor to file descriptor #0 and another invocation to
>> restore it once read has concluded. That's measurably slower where looping
>> over read.
>>
>> So here's another tangent, but has it been considered to add an option
>> to the printf builtin to print to a given file descriptor, rather than
>> stdout? If printing to a number of different file descriptors in
>> succession, such an option would appear to have all the same benefits
>> as read's -u option.
>>
>
> id like a printf -u
>
> Zack
I understand that you have pledged to use broken email software for the rest of
time but could you at least refrain from posting emails that look as though
they were signed off by someone other than yourself? It's not cricket.
--
Kerin Millar
- printf -u "$fd"?, Zachary Santer, 2024/05/17
- Re: printf -u "$fd"?, Kerin Millar, 2024/05/19
- Re: printf -u "$fd"?, alex xmb sw ratchev, 2024/05/19
- Re: printf -u "$fd"?,
Kerin Millar <=
- Re: printf -u "$fd"?, Chet Ramey, 2024/05/20
- Re: printf -u "$fd"?, Zachary Santer, 2024/05/21
- Re: printf -u "$fd"?, Chet Ramey, 2024/05/21
- Re: printf -u "$fd"?, Zachary Santer, 2024/05/21
- Re: printf -u "$fd"?, Chet Ramey, 2024/05/21
- Re: printf -u "$fd"?, Zachary Santer, 2024/05/22
- Re: printf -u "$fd"?, Zachary Santer, 2024/05/22
- Re: printf -u "$fd"?, Chet Ramey, 2024/05/22
- Re: printf -u "$fd"?, Koichi Murase, 2024/05/22