On Fri, Feb 09, 2024 at 05:21:05AM +0000, Avid Seeker wrote:
On Friday, February 9th, 2024 at 02:16, Andrew J.
Schorr<aschorr@telemetry-investments.com> wrote:
Hi,
On Fri, Feb 09, 2024 at 12:28:54AM +0000, Avid Seeker wrote:
`touch file ln -s file link awk -i inplace '{print "newline"}' link`
Results in replacing `link` with a regular file.
Thanks for the bug report. The code currently calls stat() to check whether
it's working on a regular file, and craps out if it isn't. So arguably we
should be using lstat() and failing in this case instead of stomping on the
symlink. Or do you expect the code to chase the link and replace the symlink
destination file? I think the latter is probably too much to ask...
Regards,
Andy
It's more expected for the program edits the original file. Consider how
editors like emacs don't complain when editing a symlink. In the end, the
symlink chasing is done by `readlink` function.
It could be a recursive symlink, so we'd actually need to use
realpath, not readlink. But it's not quite clear to me that this
behavior is within the scope of what the inplace extension is
supposed to do. One could debate it...
Regards,
Andy