From 13b07244fbe56f8fce606007d34f046f8a573d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Tk=C3=A1=C4=8Dik?= Date: Thu, 24 Aug 2023 10:56:40 +0200 Subject: [PATCH] Fixed config and checks --- inc/nux.cfg.nuxsh.sh | 3 +-- inc/nux.inc.sh | 10 +++++++++- inc/nux/check.inc.sh | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/inc/nux.cfg.nuxsh.sh b/inc/nux.cfg.nuxsh.sh index 2751744..c9b2f79 100644 --- a/inc/nux.cfg.nuxsh.sh +++ b/inc/nux.cfg.nuxsh.sh @@ -78,7 +78,6 @@ function :read { nux.fatal "Unknown config store $store". ;; esac - shift; :write.direct "$(nux.cfg.file.$store)" "$@" } @@ -146,7 +145,7 @@ function :read { mkdir -p "$(dirname "$file")"; touch "$file"; fi - shift; + nux.log debug "Args $@" yaml w "$file" "$@" -i } diff --git a/inc/nux.inc.sh b/inc/nux.inc.sh index 866c58d..f86e24d 100644 --- a/inc/nux.inc.sh +++ b/inc/nux.inc.sh @@ -43,6 +43,14 @@ function nux.require { } +function nux.round { + echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc)) +}; + +function nux.calc { + echo "$@" | bc +} + ## nux.use:: function nux.use { nux.log trace "nux.use: Including: $1" @@ -91,7 +99,7 @@ function nux.dirty.urlencode { function nux.url.parse { format=${2:-"protocol:\2\nuser:\4\nhost:\5\nport:\7 \npath:\8"} echo "$1" | sed \ - -re "s/(([^:\/]*):\/\/)?(([^@\/:]*)@)?([^:\/]+)(:([0-9]+))?(\/(.*))?/$format/g" + -re "s/(([^:\/]*):\/\/)?(([^@\/:]*)@)?([^:\/]+)(:([0-9]+))?([:\/](.*))?\$/$format/g" } diff --git a/inc/nux/check.inc.sh b/inc/nux/check.inc.sh index 026c5a3..0ec68e4 100644 --- a/inc/nux/check.inc.sh +++ b/inc/nux/check.inc.sh @@ -30,3 +30,7 @@ function nux.check.exec { function nux.check.file.exists { test -e "$1" -o -h "$1"; } + +function nux.check.file.symlink { + test -h "$1"; +}