From a6bd34e623a49cb69210b3df0e03216606155c41 Mon Sep 17 00:00:00 2001 From: casjay Date: Mon, 2 Sep 2024 14:31:25 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/usr/local/bin/copy rootfs/usr/local/bin/symlink --- rootfs/usr/local/bin/copy | 26 ++++++++++++++------------ rootfs/usr/local/bin/symlink | 24 +++++++++++++----------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/rootfs/usr/local/bin/copy b/rootfs/usr/local/bin/copy index 23a7156..537a2ff 100755 --- a/rootfs/usr/local/bin/copy +++ b/rootfs/usr/local/bin/copy @@ -35,10 +35,10 @@ COPY_CWD="$(realpath "$PWD")" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # script functions if [ "$SHOW_RAW" != "true" ]; then - __printf_color() { printf "%b" "$(tput setaf "${2:-7}" 2>/dev/null)" "$1\n" "$(tput sgr0 2>/dev/null)"; } + __printf_color() { printf "%b" "$(tput setaf "${2:-$DEFAULT_COLOR}" 2>/dev/null)" "$1\n" "$(tput sgr0 2>/dev/null)"; } else # Disable colorization - __printf_color() { { [ -z "$2" ] || DEFAULT_COLOR=$2; } && printf '%b\n' "$1" | tr -d '\t' | sed '/^%b$/d;s,\x1B\[ 0-9;]*[a-zA-Z],,g'; } + __printf_color() { printf '%b\n' "$1" | tr -d '\t' | sed '/^%b$/d;s,\x1B\[ 0-9;]*[a-zA-Z],,g'; } fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # check for command @@ -49,21 +49,23 @@ __function_exists() { builtin type $1 >/dev/null 2>&1 || return 1; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Define Variables -DEFAULT_COLOR="254" +DEFAULT_COLOR="7" COPY_EXIT_STATUS=0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main application { [ $# -eq 2 ] || [ "$1" = "--help" ]; } || { __printf_color "Usage: $APPNAME fromFile toFile" && exit 1; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if [ -d "$1" ]; then - mkdir -p "$2" - cp -Rf "$1/." "$2/" - COPY_EXIT_STATUS=$? -elif [ -e "$1" ]; then - cp -Rf "$1" "$2" - COPY_EXIT_STATUS=$? -else - COPY_EXIT_STATUS=2 +if [ "$1" != "$2" ]; then + if [ -d "$1" ]; then + mkdir -p "$2" + cp -Rf "$1/." "$2/" + COPY_EXIT_STATUS=$? + elif [ -e "$1" ]; then + cp -Rf "$1" "$2" + COPY_EXIT_STATUS=$? + else + COPY_EXIT_STATUS=2 + fi fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # End application diff --git a/rootfs/usr/local/bin/symlink b/rootfs/usr/local/bin/symlink index 4f7c66a..cc304c0 100755 --- a/rootfs/usr/local/bin/symlink +++ b/rootfs/usr/local/bin/symlink @@ -35,10 +35,10 @@ SYMLINK_CWD="$(realpath "$PWD")" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # script functions if [ "$SHOW_RAW" != "true" ]; then - __printf_color() { printf "%b" "$(tput setaf "${2:-7}" 2>/dev/null)" "$1\n" "$(tput sgr0 2>/dev/null)"; } + __printf_color() { printf "%b" "$(tput setaf "${2:-$DEFAULT_COLOR}" 2>/dev/null)" "$1\n" "$(tput sgr0 2>/dev/null)"; } else # Disable colorization - __printf_color() { { [ -z "$2" ] || DEFAULT_COLOR=$2; } && printf '%b\n' "$1" | tr -d '\t' | sed '/^%b$/d;s,\x1B\[ 0-9;]*[a-zA-Z],,g'; } + __printf_color() { printf '%b\n' "$1" | tr -d '\t' | sed '/^%b$/d;s,\x1B\[ 0-9;]*[a-zA-Z],,g'; } fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # check for command @@ -49,20 +49,22 @@ __function_exists() { builtin type $1 >/dev/null 2>&1 || return 1; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Define Variables -DEFAULT_COLOR="254" +DEFAULT_COLOR="7" SYMLINK_EXIT_STATUS=0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main application { [ $# -eq 2 ] || [ "$1" = "--help" ]; } || { __printf_color "Usage: $APPNAME fromFile toFile" && exit 1; } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -if [ -L "$2" ]; then - unlink "$2" -elif [ -e "$2" ]; then - rm -Rf "$2" -fi -if [ -e "$1" ]; then - ln -sf "$1" "$2" - SYMLINK_EXIT_STATUS=$? +if [ "$1" != "$2" ]; then + if [ -L "$2" ]; then + unlink "$2" + elif [ -e "$2" ]; then + rm -Rf "$2" + fi + if [ -e "$1" ]; then + ln -sf "$1" "$2" + SYMLINK_EXIT_STATUS=$? + fi fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # End application