printf -u "$fd"?

2024-05-17 Thread Zachary Santer
Was «difference between read -u fd and read <&"$fd"» on help-b...@gnu.org On Thu, May 16, 2024 at 12:51 AM Kerin Millar 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

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Martin D Kealey
On Fri, 17 May 2024 at 04:18, Chet Ramey wrote: > On 5/16/24 11:54 AM, G. Branden Robinson wrote: > > At 2024-05-16T11:36:50-0400, Chet Ramey wrote: > >> On 5/15/24 6:27 PM, Robert Elz wrote: > >>> and any attempt to use a relative path (and you > >>> can exclude ./anything or ../anything from

Re: [PATCH] globsort: handle int overflow in cmp functions

2024-05-17 Thread Grisha Levit
On Fri, May 17, 2024 at 3:06 PM Chet Ramey wrote: > > On 5/17/24 12:57 PM, Grisha Levit wrote: > > The current cmp implementation for size and blocks subtracts the two > > values and returns the difference as an int. This subtraction can > > overflow, and the returned int can end up having the

Re: [PATCH] globsort: handle int overflow in cmp functions

2024-05-17 Thread Chet Ramey
On 5/17/24 12:57 PM, Grisha Levit wrote: The current cmp implementation for size and blocks subtracts the two values and returns the difference as an int. This subtraction can overflow, and the returned int can end up having the wrong sign. This also makes the qsort comparison function

Re: [PATCH] globsort: handle int overflow in cmp functions

2024-05-17 Thread Robert Elz
Date:Fri, 17 May 2024 12:57:25 -0400 From:Grisha Levit Message-ID: <20240517165738.8896-1-grishale...@gmail.com> | The current cmp implementation for size and blocks subtracts the two | values and returns the difference as an int. This subtraction can |

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Robert Elz
Date:Fri, 17 May 2024 10:20:57 -0400 From:Chet Ramey Message-ID: | If you set the variable to something that needs it, you have to accept | the stat overhead -- otherwise, how could it do what you've requested? Of course, I understand that, I'm just not sure

[PATCH] globsort: handle int overflow in cmp functions

2024-05-17 Thread Grisha Levit
The current cmp implementation for size and blocks subtracts the two values and returns the difference as an int. This subtraction can overflow, and the returned int can end up having the wrong sign. This also makes the qsort comparison function non-transitive. (Some interesting discussion on

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Greg Wooledge
On Fri, May 17, 2024 at 03:32:23PM +, Matheus Afonso Martins Moreira wrote: > > You don't have to export variables. I would recommend not exporting > > such a variable to begin with unless you're sure of its effects. > > It could be made safe so that it's possible to export it. > Then it can

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Robert Elz
Date:Fri, 17 May 2024 10:09:06 -0400 From:Chet Ramey Message-ID: | If you don't want `.' to search $PATH, turn off the `sourcepath' shell | option. That part I assumed was already taken care of (that is, would be) just by use of the BASH_SOURCE_PATH variable.

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Matheus Afonso Martins Moreira
> As with everything. It doesn't have to be that way. It could be made so that it's harmless, so that it has no effect at all unless explicitly enabled by an option. Then there's no need to carefully manage it. Users and packagers can set it wherever they want without fear of breaking things. >

Re: [PATCH] fdopen in read -e -u N

2024-05-17 Thread Chet Ramey
On 5/17/24 4:01 AM, Grisha Levit wrote: Looks like `read -e -u N' creates (and leaks) a new stream for fd N. If a second `read' tries to fdopen the same fd once more, Android's FDSAN (on and enforcing defualt) causes the process to abort: I suppose this has value as a warning, but causing an

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Chet Ramey
On 5/16/24 10:23 PM, Matheus Afonso Martins Moreira wrote: If you don't set BASH_SOURCE_PATH (from the user's perspective; I'm not sure what I think about a loaded `library' changing the global user settings by setting it), you get the historical behavior. It's also important to consider the

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Chet Ramey
On 5/17/24 2:42 AM, Robert Elz wrote: Date:Thu, 16 May 2024 23:54:12 -0400 From:=?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Message-ID: <0b3fa8d4-7a3f-4bd6-8e8d-f7d1746be...@app.fastmail.com> | This is the description from the bash.1 that's currently in my local |

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Chet Ramey
On 5/16/24 11:36 PM, Robert Elz wrote: Date:Thu, 16 May 2024 11:36:50 -0400 From:Chet Ramey Message-ID: <613852f3-c9ef-43d8-821b-37be3d9e9...@case.edu> | You can already do this; there's no reason to add these semantics to a | variable setting. How?

Re: Stray comma in documentation of GLOBSORT

2024-05-17 Thread Chet Ramey
On 5/17/24 1:26 AM, Lawrence Velázquez wrote: The devel man page and texinfo manual both describe the upcoming GLOBSORT variable with the following sentence, which has a stray comma at the end. (I omitted it in my last message to kre.) Thanks. -- ``The lyf so short, the craft so long to

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Greg Wooledge
On Fri, May 17, 2024 at 01:42:43PM +0700, Robert Elz wrote: > [GLOBSORT] > Possibly useful I guess - though I'm not really sure about a possible > need to stat() every file from a glob result because that got set to > one of the options that needs it. "nosort" seems likely to be the most > useful

[PATCH] fdopen in read -e -u N

2024-05-17 Thread Grisha Levit
Looks like `read -e -u N' creates (and leaks) a new stream for fd N. If a second `read' tries to fdopen the same fd once more, Android's FDSAN (on and enforcing defualt) causes the process to abort: $ bash -c 'read -eu3; read -eu3' 3<&0 fdsan: failed to exchange ownership of file descriptor: fd 3

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-17 Thread Robert Elz
Date:Thu, 16 May 2024 23:54:12 -0400 From:=?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Message-ID: <0b3fa8d4-7a3f-4bd6-8e8d-f7d1746be...@app.fastmail.com> | This is the description from the bash.1 that's currently in my local | repository: Thanks. Possibly useful I