few varaible securisation, new alias hdu

This commit is contained in:
Geoffray Levasseur-Brandin
2025-06-19 14:41:31 +02:00
parent e9e9993dfc
commit 56e34bc346

View File

@@ -36,7 +36,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
if [[ ! $SHELL =~ bash|zsh ]]; then if [[ ! $SHELL =~ bash|zsh ]]; then
echo "That environmet script is designed to be used with bash or zsh being the shell." echo "That environment script is designed to be used with bash or zsh being the shell."
echo "Please consider using bash or zsh instead, or patch me ;)!" echo "Please consider using bash or zsh instead, or patch me ;)!"
return 1 return 1
fi fi
@@ -46,7 +46,7 @@ fi
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
pathremove() pathremove()
{ {
local ifs=':' local IFS=':'
local newpath local newpath
local dir local dir
local pathvar=${2:-PATH} local pathvar=${2:-PATH}
@@ -79,23 +79,23 @@ pathappend()
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Store script's path (realpath -s resolve symlinks if profile.sh is a symlink) # Store script's path (realpath -s resolve symlinks if profile.sh is a symlink)
if [[ -z $PROFILE_PATH ]]; then if [[ -z "$PROFILE_PATH" ]]; then
export MYPATH=$(dirname $(realpath -s $0)) export MYPATH=$(dirname "$(realpath -s "$0")")
else else
export MYPATH=$PROFILE_PATH export MYPATH="$PROFILE_PATH"
fi fi
if [[ ! -e $MYPATH/profile.sh ]]; then if [[ ! -e "$MYPATH/profile.sh" ]]; then
echo "[ Warning ] Path detection failed, trying to use pwd..." echo "[ Warning ] Path detection failed, trying to use pwd..."
MYPATH=$(pwd) MYPATH=$(pwd)
if [[ ! -e $MYPATH/profile.sh ]]; then if [[ ! -e "$MYPATH/profile.sh" ]]; then
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work." echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
fi fi
fi fi
if [[ ! -s $MYPATH/version ]]; then if [[ ! -s "$MYPATH/version" ]]; then
echo "[ Warning ] Impossible to determine running version of profile, your installation might be broken." echo "[ Warning ] Impossible to determine running version of profile, your installation might be broken."
fi fi
export PROFVERSION=$(cat $MYPATH/version) export PROFVERSION=$(cat "$MYPATH"/version)
# Build PATH environment variable # Build PATH environment variable
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
@@ -175,6 +175,7 @@ if [[ $INTERACTIVE ]]; then
alias du='du -ch' alias du='du -ch'
alias sdu='du -sk ./* | sort -n' alias sdu='du -sk ./* | sort -n'
alias hdu='du -hs ./* | sort -H'
# Define PS1 # Define PS1
trap 'timer_start' DEBUG trap 'timer_start' DEBUG