From c2c0a11402f12ee09009447c0530d41c28902ee4 Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Fri, 28 Jun 2024 10:28:56 +0000 Subject: [PATCH] feat: Corrections shellcheck --- libs/basedir.bash | 2 +- libs/note.bash | 10 +++++----- libs/password.bash | 14 +++++++------- libs/ssh.bash | 8 +++----- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/libs/basedir.bash b/libs/basedir.bash index d3acf8b..28e6da1 100755 --- a/libs/basedir.bash +++ b/libs/basedir.bash @@ -1,5 +1,5 @@ #!/bin/bash function basedir() { - echo $( cd $(dirname $0) && pwd ) + (cd "$(dirname \"$-2\")" && pwd) } diff --git a/libs/note.bash b/libs/note.bash index 3e2416e..49bc104 100644 --- a/libs/note.bash +++ b/libs/note.bash @@ -1,19 +1,19 @@ #!/bin/bash -note () { +note() { # if file doesn't exist, create it if [[ ! -f $HOME/.notes ]]; then - touch $HOME/.notes + touch "$HOME"/.notes fi if [[ $# -eq 0 ]]; then # no arguments, print file - cat $HOME/.notes + cat "$HOME"/.notes elif [[ "$1" == "-c" ]]; then # clear file - echo "" > $HOME/.notes + echo "" >"$HOME"/.notes else # add all arguments to file - echo "$@" >> $HOME/.notes + echo "$@" >>"$HOME"/.notes fi } diff --git a/libs/password.bash b/libs/password.bash index 87c26dd..cf636a7 100755 --- a/libs/password.bash +++ b/libs/password.bash @@ -1,19 +1,19 @@ #!/bin/bash encpasswd() { - local password_clear=$1 - local password_md5hash=$(openssl passwd -1 $password_clear) - local password_sha1=$(echo -n $password_clear | openssl dgst -sha1) + local password_clear=$1 + local password_md5hash=$(openssl passwd -1 "$password_clear") + local password_sha1=$(echo -n "$password_clear" | openssl dgst -sha1) echo "Password : $password_clear" echo "MD5HASH : $password_md5hash" echo "SHA1 : $password_sha1" } genpasswd() { - local l=$1 - [ "$l" == "" ] && l=12 - local password_clear=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs) - local password_md5hash=$(openssl passwd -1 $password_clear) + local l=$1 + [ "$l" == "" ] && l=12 + local password_clear=$(tr -dc A-Za-z0-9_