From 404f8d0a0aad0747c53ad44b894524817ac53f3d Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Sun, 22 Jan 2017 23:41:25 +0200 Subject: [PATCH] Make the script OSX compatible - Use shorthand flags for `rm`: `-r` instead of `--recursive`, `-f` instead of `--force` - Add fallbacks for `mktemp`. See http://unix.stackexchange.com/a/84980 - Use shorthand flags for `cut`: `-d` instead of `--delimiter`, `-f` instead of `--fields` Tested on OSX 10.11.6 El Capitan --- AAXtoMP3.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AAXtoMP3.sh b/AAXtoMP3.sh index 4f3ef24..63bd2f7 100755 --- a/AAXtoMP3.sh +++ b/AAXtoMP3.sh @@ -35,8 +35,8 @@ debug() { echo "$(date "+%F %T%z") ${1}" } -trap 'rm --recursive --force "${working_directory}"' EXIT -working_directory="$(mktemp --directory)" +trap 'rm -r -f "${working_directory}"' EXIT +working_directory=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` metadata_file="${working_directory}/metadata.txt" save_metadata() { @@ -48,7 +48,7 @@ save_metadata() { get_metadata_value() { local key key="$1" - normalize_whitespace "$(grep --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut --delimiter=: --fields=2 | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')" + normalize_whitespace "$(grep --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2 | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')" } get_bitrate() {