diff options
| Commit | 7dba46a34aa2d13bc2edf6829313ad442c2fe81e (patch) | |
|---|---|---|
| Author | 2026-11-08 14:56:49 +0200 | |
| Committer | 2026-11-08 14:56:49 +0200 | |
| Files | c8e918c7538a1b6be35b58f1d43437cf30f46c92 /make | |
| .files-7dba46a34aa2d13bc2edf6829313ad442c2fe81e.tar .files-7dba46a34aa2d13bc2edf6829313ad442c2fe81e.tar.gz .files-7dba46a34aa2d13bc2edf6829313ad442c2fe81e.zip | ||
| Parent | fbc352119e3e4fa37546ac8ad62989c87162888e (diff) | |
feat(make): Implemented safe linking
Its primary use is with export: if you export a file and make changes,
normal link automatically imports it, while safe_link leaves it as-is.
Since you have to explicitly specify which files to export, this
effectively preserves the export. For this reason also it is made the
default action.
There are some minor drawbacks: when setting up a new system, you'll
need to run "./make link" instead of just "./make". Also, if you want to
force a subdir to be linked, you'll either have to re-export the
exported files after link or temporarily modify the SYSTEM file.
However, this should be ammendable with extended argument parsing.
1 files changed, 9 insertions, 1 deletions
| -rwxr-xr-x | make | 10 |
@@ -19,6 +19,7 @@ then exit 1 fi +no_overwrite= # __merge_link <.FILES_DIR> <HOME_DIR> __merge_link() { while read -r f @@ -48,6 +49,12 @@ __merge_link() { # replace output file with (link to) current if ! cmp -s "$1/$f" "$2/$f" then + if [ -n "$no_overwrite" ] + then + echo "Warn: '$2/$f' is different from '$1/$f', skipping (./make safe_link is being executed)!" >/dev/stderr + continue + fi + if [ -h "$2/$f" ] then real="$(readlink "$2/$f")" @@ -276,5 +283,6 @@ case "$1" in (import) import "$@" ;; (export) export_ "$@" ;; (unlink) unlink ;; - (link|*) link ;; + (link) link ;; + (safe_link|sink|*) no_overwrite=yes; link ;; esac |
