From d3c98dd7369788679a2edfc0050ef987b761166f Mon Sep 17 00:00:00 2001 From: fatalerrors Date: Tue, 8 Nov 2022 16:04:14 +0100 Subject: [PATCH] v3.0.1: many small improvement and bugfix --- profile.d/compress.sh | 2 +- profile.d/debug.sh | 4 ++-- profile.d/filefct.sh | 20 ++++++++++++++------ profile.d/help.sh | 4 +++- profile.d/info.sh | 7 +++++-- profile.sh | 6 ++++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/profile.d/compress.sh b/profile.d/compress.sh index 4d6df4f..e1bd540 100644 --- a/profile.d/compress.sh +++ b/profile.d/compress.sh @@ -255,7 +255,7 @@ taz () ;; "-"[1..9]) - local complevel=${opt:1:1} + local complevel=$(echo $opt | sed 's/-//') ;; "-"*) diff --git a/profile.d/debug.sh b/profile.d/debug.sh index 81b3af9..ee751b0 100644 --- a/profile.d/debug.sh +++ b/profile.d/debug.sh @@ -25,7 +25,7 @@ function error () { local errcode=$? backtrace - exit $errcode + return $errcode } @@ -36,7 +36,7 @@ settrace () { local status="off" [[ $(trap -p ERR) ]] && status="on" - trap -p ERR + #trap -p ERR for opt in $@ ; do case $opt in "-h"|"--help") diff --git a/profile.d/filefct.sh b/profile.d/filefct.sh index 33e1dba..4d4974e 100644 --- a/profile.d/filefct.sh +++ b/profile.d/filefct.sh @@ -114,8 +114,11 @@ rmspc () echo " -c, --subst-char Change the replacement character (default is underscore)" echo " -v, --verbose Display what is being done" echo " -s, --shell Do nothing and display commands that would be executed" - echo - return 0 + echo + echo "Note: if the --subst-char option is given without parameters, spaces will be" + echo " replaced with nothing (concatenation)." + echo + return 0 ;; "-r"|"--recursive") @@ -123,11 +126,15 @@ rmspc () ;; "-c"?*|"--subst-char"?*) - local substchar=$(echo "$opt" | cut -f 2- -d '=') - ;; + if [[ $(echo $opt | grep "=") ]]; then + local substchar=$(echo "$opt" | cut -f 2- -d '=') + else + local substchar='none' + fi + ;; - "-v"|"--verbose") - local verb=1 + "-v"|"--verbose") + local verb=1 ;; "-s"|"--shell") @@ -143,6 +150,7 @@ rmspc () done [[ ! $substchar ]] && substchar="_" + [[ $substchar == "none" ]] && local substchar="" [[ $verb ]] && local mvopt="-v" for f in *; do diff --git a/profile.d/help.sh b/profile.d/help.sh index ca92c12..40b5b8a 100644 --- a/profile.d/help.sh +++ b/profile.d/help.sh @@ -1,7 +1,7 @@ # ------------------------------------------------------------------------------ # Display list of commands and general informations # ------------------------------------------------------------------------------ -help () +help() { cat < --help to obtain usage details. EOF } export -f help diff --git a/profile.d/info.sh b/profile.d/info.sh index fc5fb10..1e33052 100644 --- a/profile.d/info.sh +++ b/profile.d/info.sh @@ -17,7 +17,7 @@ meteo () [[ $# -eq 0 ]] && local cities=$DEFAULT_CITY for city in $cities; do - curl https://wttr.in/$city + curl https://wttr.in/$city || echo "Failed fetching datas for $city." done } export -f meteo @@ -30,7 +30,10 @@ showinfo() { echo -e "\n" if command -v figlet >/dev/null 2>&1; then - figlet -k $(hostname) + if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then + local figopt="-f ansi_shadow" + fi + figlet -k $(hostname) $figopt else echo "$(hostname -f)" fi diff --git a/profile.sh b/profile.sh index 6568c65..1b14691 100644 --- a/profile.sh +++ b/profile.sh @@ -33,6 +33,7 @@ # 19/07/2022 v2.8.1 : few cleanup, fixes and optimizations # 29/07/2022 v2.8.2 : added warning for non bash users # 27/08/2022 v3.0.0 : splitted everything, added rain screensaver +# 07/11/2022 v3.0.1 : added concatenation to rmspc, added ku, error managed in meteo # ------------------------------------------------------------------------------ # Copyright (c) 2013-2022 Geoffray Levasseur # Protected by the BSD3 license. Please read bellow for details. @@ -68,7 +69,7 @@ # * OF SUCH DAMAGE. # ------------------------------------------------------------------------------ -export PROFVERSION="3.0.0" +export PROFVERSION="3.0.1" export DEFAULT_CITY="Toulouse" @@ -200,4 +201,5 @@ fi unset pathremove pathprepend pathappend #return 0 -# End /etc/profile + +# End profile.sh