From 76cbf503927067cf882a9173be03785c2850e19f Mon Sep 17 00:00:00 2001 From: Holger Just Date: Wed, 22 Jan 2025 00:21:35 +0100 Subject: [PATCH] Better variable quoting in delink function --- .bashrc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index 5059795..3957898 100644 --- a/.bashrc +++ b/.bashrc @@ -3,15 +3,18 @@ # Function to resolve soft links function delink() { - f=$1 + local f="$1" + local ls link while [[ -h "$f" ]]; do - ls=`ls -ld "$f"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then f="$link" - else f=`dirname "$f"`/"$link" + ls="$(ls -ld "$f")" + link="$(expr "$ls" : '.*-> \(.*\)$')" + if expr "$link" : '/.*' > /dev/null; then + f="$link" + else + f="$(dirname "$f")/${link}" fi done - echo $f + echo "$f" } # General Settings