From f3e0fb21f07ee7dd49dd59f7ffd88c9a60fc6bc9 Mon Sep 17 00:00:00 2001 From: Bernd Schumacher Date: Tue, 30 Oct 2018 13:27:57 +0100 Subject: [PATCH 1/2] Set $XDG_CONFIG_HOME and $VCSH_BASE based on existing .config/vcsh --- vcsh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/vcsh b/vcsh index d1d26edd..20e0090e 100755 --- a/vcsh +++ b/vcsh @@ -61,6 +61,29 @@ source_all() { # Read configuration and set defaults if anything's not set [ -n "$VCSH_DEBUG" ] && set -vx + +# Set $XDG_CONFIG_HOME and $VCSH_BASE based on existing .config/vcsh +# (To create a new $VCSH_BASE: mkdir -p $VCSH_BASE/.config/vcsh) +if [ ! -n "$XDG_CONFIG_HOME" ] && [ ! -n "$VCSH_BASE" ]; then + # Search for .config/vcsh in actual directory path + VCSH_BASE="$(realpath .)" + while :; do + if [ -d "$VCSH_BASE/.config/vcsh" ]; then + break + elif [ "$VCSH_BASE" = "/" ]; then + VCSH_BASE="" + break + else + VCSH_BASE="$(dirname "$VCSH_BASE")" + fi + done + if [ "$VCSH_BASE" ]; then + # Check Permission denied problems + find "$VCSH_BASE/.config/" >/dev/null || fatal "problem reading files in $VCSH_BASE/.config/" + XDG_CONFIG_HOME="$VCSH_BASE/.config" + fi +fi + : ${XDG_CONFIG_HOME:="$HOME/.config"} # Read configuration files if there are any From 189f0c0703e997141c25d790465c5ad91cfdf573 Mon Sep 17 00:00:00 2001 From: Bernd Schumacher Date: Tue, 30 Oct 2018 15:04:47 +0100 Subject: [PATCH 2/2] do not use realpath --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 20e0090e..134b437a 100755 --- a/vcsh +++ b/vcsh @@ -66,7 +66,7 @@ source_all() { # (To create a new $VCSH_BASE: mkdir -p $VCSH_BASE/.config/vcsh) if [ ! -n "$XDG_CONFIG_HOME" ] && [ ! -n "$VCSH_BASE" ]; then # Search for .config/vcsh in actual directory path - VCSH_BASE="$(realpath .)" + VCSH_BASE="$(pwd)" while :; do if [ -d "$VCSH_BASE/.config/vcsh" ]; then break