aboutsummaryrefslogtreecommitdiff
path: root/scripts/install-multi-user.sh
diff options
context:
space:
mode:
authorMatthew Kenigsberg <matthewkenigsberg@gmail.com>2023-03-02 17:29:36 -0700
committerMatthew Kenigsberg <matthew@floxdev.com>2023-05-25 08:59:05 -0600
commit367fcd9eb590d002cbbae23f22b1395b7d3303e6 (patch)
tree4daa587710c39f20c1bef579524d021a45edb852 /scripts/install-multi-user.sh
parent8730d3002f9834a1c9c45bc50fd4c46458ae6eef (diff)
installer: don't assume GNU diff
macOS Ventura ships with it's own version of diff. Try to output a similar diff with Apple diff as with GNU diff, instead of failing Helps https://github.com/NixOS/nix/issues/7286
Diffstat (limited to 'scripts/install-multi-user.sh')
-rw-r--r--scripts/install-multi-user.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/install-multi-user.sh b/scripts/install-multi-user.sh
index 7c66538b0..79deb2819 100644
--- a/scripts/install-multi-user.sh
+++ b/scripts/install-multi-user.sh
@@ -246,8 +246,15 @@ printf -v _OLD_LINE_FMT "%b" $'\033[1;7;31m-'"$ESC ${RED}%L${ESC}"
printf -v _NEW_LINE_FMT "%b" $'\033[1;7;32m+'"$ESC ${GREEN}%L${ESC}"
_diff() {
+ # macOS Ventura doesn't ship with GNU diff. Print similar output except
+ # without +/- markers or dimming
+ if diff --version | grep -q "Apple diff"; then
+ printf -v CHANGED_GROUP_FORMAT "%b" "${GREEN}%>${RED}%<${ESC}"
+ diff --changed-group-format="$CHANGED_GROUP_FORMAT" "$@"
+ else
# simple colorized diff comatible w/ pre `--color` versions
- diff --unchanged-group-format="$_UNCHANGED_GRP_FMT" --old-line-format="$_OLD_LINE_FMT" --new-line-format="$_NEW_LINE_FMT" --unchanged-line-format=" %L" "$@"
+ diff --unchanged-group-format="$_UNCHANGED_GRP_FMT" --old-line-format="$_OLD_LINE_FMT" --new-line-format="$_NEW_LINE_FMT" --unchanged-line-format=" %L" "$@"
+ fi
}
confirm_rm() {