[UPDATE][SHELL] Add quote to variable expansions

Everyone assumes that spaces do not exist on a Linux system... This is
unfortunately not the case (although I hate having spaces in my own
files). Quoting the variables avoids running into those kind of issues.
This commit is contained in:
Bruno BELANYI 2019-10-04 16:28:53 +02:00
parent 6d17f7ac54
commit 5723876694

View file

@ -37,21 +37,21 @@ fi
# jump directorys upwards until it hits a directory with multiple folders # jump directorys upwards until it hits a directory with multiple folders
function up() { function up() {
local d="" local d=""
limit=$1 limit="$1"
for ((i=1 ; i <= limit ; i++)) for ((i=1 ; i <= limit ; i++))
do do
d=$d/.. d="$d/.."
done done
d=$(echo $d | sed 's/^\///') d=$(echo "$d" | sed 's/^\///')
if [ -z "$d" ]; then if [ -z "$d" ]; then
d=.. d=..
fi fi
cd $d cd "$d"
} }
# create an directory and directly cd into it # create an directory and directly cd into it
function mcd () { function mcd() {
mkdir -p $1 mkdir -p "$1"
cd $1 cd "$1"
} }