From 93b02c51612ed0c68cd1d8c71916c143e99f7403 Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Fri, 12 Apr 2019 13:46:41 +0300 Subject: [PATCH] little workaround BSD abspaths --- bin/abs-path | 1 + files/abs-path | 6 ++++++ files/cp-progress | 2 +- files/rm-safe | 2 +- files/rm_bg | 2 +- reporting/md-site | 2 +- reporting/qolop | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) create mode 120000 bin/abs-path create mode 100755 files/abs-path diff --git a/bin/abs-path b/bin/abs-path new file mode 120000 index 0000000..5fc72c5 --- /dev/null +++ b/bin/abs-path @@ -0,0 +1 @@ +../files/abs-path \ No newline at end of file diff --git a/files/abs-path b/files/abs-path new file mode 100755 index 0000000..4e30be9 --- /dev/null +++ b/files/abs-path @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +case $OSTYPE in + darwin*) exec realpath "$1" ;; + *) exec readlink -f "$1" ;; +esac diff --git a/files/cp-progress b/files/cp-progress index 751f92f..d4400af 100755 --- a/files/cp-progress +++ b/files/cp-progress @@ -46,7 +46,7 @@ copy_dir() { chmod --reference="$1" "$2" chown --reference="$1" "$2" mysize=$( getsize "$1" ) - TGT_ABS=$( readlink -f "$2" ) + TGT_ABS=$( abs-path "$2" ) pushd "$1" &> /dev/null tar -c "." | pv -s $mysize | tar -x --strip-components=1 -C "$TGT_ABS" popd &> /dev/null diff --git a/files/rm-safe b/files/rm-safe index 786db5a..b0a2f9d 100755 --- a/files/rm-safe +++ b/files/rm-safe @@ -41,7 +41,7 @@ mkdir -p "$SAFELOC" now=$( date -Idate ) for d in "${FOLDERS[@]}"; do if [[ ! -e "$d" ]]; then continue; fi - path=$( readlink -f "$d" ) + path=$( abs-path "$d" ) dir=$( dirname "$path" ) if [[ "$VERBOSE" -eq 1 ]]; then echo "$SAFELOC/$now/$path"; fi if [[ -e "$SAFELOC/$now/$path" ]]; then file-version $QUIET "$SAFELOC/$now/$path"; fi diff --git a/files/rm_bg b/files/rm_bg index 65fe8d2..a2f171e 100755 --- a/files/rm_bg +++ b/files/rm_bg @@ -15,7 +15,7 @@ for f in "$@"; do echo "$f" does not exist continue } - d=$( readlink -nf $( dirname "$f" ) )/.rm_bg.$$ + d=$( abs-path $( dirname "$f" ) )/.rm_bg.$$ mkdir -p "$d" mv "$f" "$d"/ tempfolders+=( "$d" ) diff --git a/reporting/md-site b/reporting/md-site index a6220ae..2f77996 100755 --- a/reporting/md-site +++ b/reporting/md-site @@ -92,7 +92,7 @@ for (( i=1; i<=$#; i++ )); do [[ "${!i}" = "-h" ]] && _help [[ "${!i}" = *"help" ]] && _help done -SELF=$( dirname $( readlink -f "$0" ) ) +SELF=$( dirname $( abs-path "$0" ) ) [[ "$1" == build ]] && _build "$2" "$3" [[ "$1" == autobuild ]] && _autobuild "$2" "$3" diff --git a/reporting/qolop b/reporting/qolop index 8a3193f..077e7f1 100755 --- a/reporting/qolop +++ b/reporting/qolop @@ -1,5 +1,5 @@ #!/bin/bash -_qColVersion() { echo Version 2018.12.23.0; } +_qColVersion() { echo Version 2019.04.12.0; } _qColHelp() { _qColVersion