thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

GNU sed: follow symlinks

β€’ 80 words β€’ 1 min β€’ updated

Previously.

Today we will upgrade Terraform in the entire codebase:

shell
fd -e tf | ifne xargs gsed -i -e 's/required_version = "~> 1.6.6/required_version = "~> 1.10.0/g'

Easy, right?

During code review, a teammate has pointed out that I replaced many symlinks. How?! This was completely unintended!

Eventually I figured out the reason. From sed(1):

--follow-symlinks

follow symlinks when processing in place

It turns out it is necessary to pass --follow-symlinks to preserve symlinks when using -i with GNU sed.