‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, May 16, 2019 10:57 PM, Chet Ramey <chet.ra...@case.edu> wrote:
> On 5/16/19 4:25 PM, howaboutsyne...@protonmail.com wrote: > > > Hi. Would bash devs even consider replacing the current behaviour of ">" > > (redirection) to do the equivalent of the following(under the hood) ? > > I doubt it. That's not how it's defined to behave, and there's no good > reason to do it. Thanks. On second thought, there's a reason bash devs should not do it: O_APPEND may lead to corrupted files on NFS filesystems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition. - from `man 2 open` > > > When: > > `command > $somewhere` > > then actually do(under the hood): > > : > $somewhere > > command >> $somewhere > > ie. create&truncate file, then open it in append mode and redirect to it, > > instead of what it currently does(aka not append). > > Why not just use the version you supply above in the cases where it > matters? I'm indeed doing that for /usr/share/automake-1.16/test-driver, but I was hoping to future proof it for unknown situations. To answer my own question: > If not, could the devs(or anyone) please suggest a place in the source code > where to look for attempting to implement/change this for myself? in ./make_cmd.c function `make_redirection`, code: case r_output_direction: /* >foo */ case r_output_force: /* >| foo */ case r_err_and_out: /* &>filename */ temp->flags = O_TRUNC | O_WRONLY | O_CREAT; break; Addind O_APPEND there didn't immediately hurt, and ./redir.c function `do_redirection_internal` something there... I'll try some things. > > ------------------------------------------------------------------------------- > > `The lyf so short, the craft so long to lerne.'' - Chaucer`Ars longa, vita > brevis'' - Hippocrates > Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
publickey - howaboutsynergy@protonmail.com - 0x947B9B34.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature