Last active
January 10, 2022 22:21
-
-
Save abathur/6189c15922c918171e18728ef3563594 to your computer and use it in GitHub Desktop.
Confirming how portable this diff invocation is/isn't on any OS you can/want to install Nix on that isn't already in reports! This tries each diff on PATH, but I'm interested in default and common user-installed diffs (leave out any uncommon build you have). See 1st comment for a screenshot of expected output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
readonly ESC='\033[0m' | |
readonly GREEN='\033[32m' | |
readonly RED='\033[31m' | |
printf -v _UNCHANGED_GRP_FMT "%b" $'\033[2m%='"$ESC" # "dim" | |
# bold+invert+red and bold+invert+green just for the +/- below | |
# red/green foreground for rest of the line | |
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}" | |
for diff in $(type -ap diff); do | |
$diff --unchanged-group-format="$_UNCHANGED_GRP_FMT" --old-line-format="$_OLD_LINE_FMT" --new-line-format="$_NEW_LINE_FMT" --unchanged-line-format=" %L" <(echo one && echo two && echo three) <(echo one && echo tow && echo three) | |
echo "^^^ status: $? for $($diff --version | head -n 1) ($diff)" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
working | |
macOS 10.14, 10.15, 10.16 | |
stock: (GNU diffutils) 2.8.1 (/usr/bin/diff) | |
fink, homebrew, macports, pkgsrc: I haven't found an obvious bin/diff except the one in diffutils, which should be fine | |
centOS 6 | |
not working | |
* nixpkgs plan9port/bin/diff (completely incompatible: diff [ -acefmnbwr ] file1 ... file2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected output is something like:
