Using regular os.Open on symlink, formatting and writing back the output breaks the link and creates a new file instead.
Following a symlink automatically is something to decide. Do we trust the use to have done due diligence when passing a symlink OR avoid surprise and return an error for symlinks?
This change resolves the symlink and operates on resolved path, updates the source path and retains the symlink.
Fix for: https://github.com/mvdan/sh/issues/1053
Using regular
os.Open
on symlink, formatting and writing back the output breaks the link and creates a new file instead.Following a symlink automatically is something to decide. Do we trust the use to have done due diligence when passing a symlink OR avoid surprise and return an error for symlinks?
This change resolves the symlink and operates on resolved path, updates the source path and retains the symlink.