aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/shell16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/keyringer/actions/shell b/lib/keyringer/actions/shell
index d8a0ef7..d9a3e07 100755
--- a/lib/keyringer/actions/shell
+++ b/lib/keyringer/actions/shell
@@ -18,19 +18,27 @@ while read -rep "keyringer:/${KEYRING}${SHELLPATH}> " STDIN; do
# Update current path
OLDPATH="$SHELLPATH"
- SHELLPATH="/`echo $STDIN | sed -e 's/^cd//' | cut -d ' ' -f 2`"
+ SHELLPATH="`echo $STDIN | sed -e 's/^cd//' | cut -d ' ' -f 2`"
# Fix current path
- if [ "$SHELLPATH" == "/" ]; then
+ if [ "$SHELLPATH" == "/" ] || [ "$SHELLPATH" == "" ]; then
SHELLPATH="/"
- elif [[ "$SHELLPATH" == "/.."* ]]; then
+ elif [[ "$SHELLPATH" == ".."* ]]; then
ARGS="$SHELLPATH"
SHELLPATH="$OLDPATH"
for colons in `echo $ARGS | sed -e 's|/| |g'`; do
- SHELLPATH="`dirname $SHELLPATH`"
+ SHELLPATH="`dirname $SHELLPATH | sed -e 's|^\.||'`"
done
fi
+ # Ensure path is absolute
+ if echo "$SHELLPATH" | grep -v -q -e "^/"; then
+ SHELLPATH="/$OLDPATH/$SHELLPATH"
+ fi
+
+ # Removing multiple slashes
+ SHELLPATH="`echo $SHELLPATH | sed -e 's/\/\+/\//g'`"
+
# Check if path exists
if [ ! -d "$KEYDIR/$SHELLPATH" ]; then
echo "No such folder $SHELLPATH"