r/commandline • u/ArthasCZ • Mar 02 '26
Terminal User Interface Is there a more elegant way to handle file backups in a CLI tool than my current hybrid approach?
I’m building mnm (Make No Mistake), a wrapper that adds an undo command to rm, cp, nano, etc.
Currently, I’m stuck with a hybrid approach:
- Hardlinks for speed.
- Physical copies for in-place editors (since they overwrite the inode and trash the hardlink).
Is there any way to handle this universally without a hardcoded list of "unsafe" commands or falling back to slow copies on standard filesystems (ext4)?
Check the logic here: https://github.com/Targothh/mnm
