From 9401e3e2427cf4acacb9e140c581cd1b42f1d724 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 2 Mar 2023 23:08:03 +0000 Subject: [PATCH] Always use /usr/bin/xattr To avoid picking up user-installed xattr copies with potentially different behaviour, such as missing support for the `-x` option. Fixes #42 --- bin/fileicon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/fileicon b/bin/fileicon index b0f975e..22aa48a 100755 --- a/bin/fileicon +++ b/bin/fileicon @@ -116,7 +116,7 @@ esac # IMPORTANT: Hex. digits > 9 use UPPPERCASE characters. # getAttribByteString getAttribByteString() { - xattr -px "$2" "$1" | tr -d ' \n' + /usr/bin/xattr -px "$2" "$1" | tr -d ' \n' return ${PIPESTATUS[0]} } @@ -173,7 +173,7 @@ patchByteInByteString() { # hasAttrib hasAttrib() { - xattr "$1" | /usr/bin/grep -Fqx "$2" + /usr/bin/xattr "$1" | /usr/bin/grep -Fqx "$2" } # hasIconData @@ -354,9 +354,9 @@ removeCustomIcon() { if hasAttrib "$fileOrFolder" com.apple.FinderInfo; then byteStr=$(getAttribByteString "$fileOrFolder" com.apple.FinderInfo | patchByteInByteString $kFI_BYTEOFFSET_CUSTOMICON '~'$kFI_VAL_CUSTOMICON) || return if [[ $byteStr == "$kFI_BYTES_BLANK" ]]; then # All bytes cleared? Remove the entire attribute. - xattr -d com.apple.FinderInfo "$fileOrFolder" + /usr/bin/xattr -d com.apple.FinderInfo "$fileOrFolder" else # Update the attribute. - xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return + /usr/bin/xattr -wx com.apple.FinderInfo "$byteStr" "$fileOrFolder" || return fi fi @@ -365,7 +365,7 @@ removeCustomIcon() { rm -f "$(getFileWithIconData "$fileOrFolder")" else # file -> remove the resource fork if hasIconData "$fileOrFolder"; then - xattr -d com.apple.ResourceFork "$fileOrFolder" + /usr/bin/xattr -d com.apple.ResourceFork "$fileOrFolder" fi fi