From a9caea4d64233ebe7b38c5aad4199da378f7614c Mon Sep 17 00:00:00 2001 From: Quinn Date: Tue, 13 Aug 2019 22:41:48 -0500 Subject: [PATCH] More WIndwos (cygwin) updates Add install_file_cygwin function to support this case --- src/install/rewrite.txt | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/install/rewrite.txt b/src/install/rewrite.txt index 86c0ef50..9fe183bb 100644 --- a/src/install/rewrite.txt +++ b/src/install/rewrite.txt @@ -392,6 +392,43 @@ install_file_linux() { return "${rcode}" } +#--- FUNCTION ---------------------------------------------------------------- +# NAME: install_file_cygwin +# DESCRIPTION: Installs a file into a location using 'install'. If EUID not +# 0, then attempt to use sudo. +# PARAMETERS: $1 = file to install +# $2 = location to install file into +# RETURNS: 0 = File Installed +# 1 = File not installed +# 2 = Could not find install command +#------------------------------------------------------------------------------- +install_file_linux() { + local file + local prefix + local rcode + + file="${1}" + prefix="${2}" + + if command -v install >/dev/null 2>&1; then + if [[ "${EUID}" == "0" ]]; then + install -m 755 "${prefix}" "${file}" + rcode="${?}" + else + if command -v sudo >/dev/null 2>&1; then + sudo install -m 755 "${file}" "${prefix}" + rcode="${?}" + else + rcode="3" + fi + fi + else + rcode="2" + fi + + return "${rcode}" +} + #--- FUNCTION ---------------------------------------------------------------- # NAME: main # DESCRIPTION: Put it all together in a logical way