From 7dba46a34aa2d13bc2edf6829313ad442c2fe81e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 8 Nov 2026 14:56:49 +0200 Subject: 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. --- make | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'make') diff --git a/make b/make index e9ee9c3..ae424fe 100755 --- a/make +++ b/make @@ -19,6 +19,7 @@ then exit 1 fi +no_overwrite= # __merge_link <.FILES_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 -- cgit v1.3.1-26-gb76a