diff --git a/scripts/retdec-archive-decompiler.sh b/scripts/retdec-archive-decompiler.sh index d86f5c2d1..2469924f7 100644 --- a/scripts/retdec-archive-decompiler.sh +++ b/scripts/retdec-archive-decompiler.sh @@ -3,10 +3,6 @@ # Runs the decompilation script with the given arguments over all files in the # given static library. # -# Requirements: -# - bash -# - the `timeout` command -# # On macOS, we want the GNU version of 'readlink', which is available under # 'greadlink': @@ -27,17 +23,6 @@ fi . "$DECOMPILER_UTILS" -## -## Check that all script requirements are satisfied. -## -for CMD in "timeout"; do - command -v $CMD > /dev/null 2>&1 || { - echo "error: The \`$CMD\` command is required but it is not" \ - "available. Aborting." >&2 - exit 1 - } -done - ## ## Configuration. ## @@ -187,7 +172,7 @@ for ((INDEX=0; INDEX "$LOG_FILE" 2>&1 + gnutimeout $TIMEOUT "$DECOMPILE_SH" --ar-index="$INDEX" -o "$LIBRARY_PATH.file_$FILE_INDEX" "$LIBRARY_PATH" $DECOMPILE_SH_ARGS > "$LOG_FILE" 2>&1 RC=$? # Print status. diff --git a/scripts/retdec-utils.sh b/scripts/retdec-utils.sh index efaf39c18..82ee7ddbd 100644 --- a/scripts/retdec-utils.sh +++ b/scripts/retdec-utils.sh @@ -22,6 +22,17 @@ fi . "$DECOMPILER_CONFIG" +# On macOS, 'timeout' from GNU coreutils is by default available under +# 'gtimeout'. +gnutimeout() +{ + if hash gtimeout 2> /dev/null; then + gtimeout "$@" + else + timeout "$@" + fi +} + # # Prints the real, physical location of a directory or file, relative or # absolute.