From 855e4e83970fdfa12b79d72b1a7f095165051167 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Tue, 17 Jul 2018 15:22:40 +0200 Subject: [PATCH] Detect coreutils with g prefix for macOS brew support. --- home/bin/update-profile | 7 ++++++- install.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/home/bin/update-profile b/home/bin/update-profile index 329fa53..d468008 100755 --- a/home/bin/update-profile +++ b/home/bin/update-profile @@ -1,5 +1,10 @@ #!/bin/sh -e +CUT="gcut" +if ! command -v "${READLINK}" 2>&1; then + CUT="cut" +fi + file_changed() { if [ ! -f "$1" ]; then if [ ! -f "$2" ]; then @@ -55,7 +60,7 @@ fi fi git rev-list --format=oneline "${diffref}" | while IFS= read -r line; do sha="$(echo "$line" | awk '{print $1}')" - title="$(echo "$line" | cut -f 1 -d ' ' --complement)" + title="$(echo "$line" | "${CUT}" -f 1 -d ' ' --complement)" printf " … $title\r " if ! git verify-commit "$sha" >/dev/null 2>&1; then echo "✘" diff --git a/install.sh b/install.sh index 5116503..9f9748b 100755 --- a/install.sh +++ b/install.sh @@ -1,13 +1,17 @@ #!/bin/sh -e +READLINK="greadlink" +if ! command -v "${READLINK}" 2>&1; then + READLINK="readlink" +fi install_files() { target_dir="$1" - source_dir="$(readlink -f "${2:-.}")" + source_dir="$("${READLINK}" -f "${2:-.}")" target_filename_prefix="${3}" mkdir -vp "${target_dir}" - target_dir="$(readlink -f "${target_dir}")" + target_dir="$("${READLINK}" -f "${target_dir}")" if [ ! -d "${source_dir}" ]; then echo "Source directory ${source_dir} does not exist, skipping."