From 0d862493f29913c2a07541d264a4b48658bbf481 Mon Sep 17 00:00:00 2001 From: Harald Lapp Date: Thu, 14 Apr 2016 02:58:51 +0200 Subject: [PATCH] resolve origin user when using rmate with sudo to fix the problem that a config-file could not be loaded from ~ of origin user if rmate is executed using sudo --- rmate | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rmate b/rmate index cdc5704..0b0d205 100755 --- a/rmate +++ b/rmate @@ -57,6 +57,7 @@ hostname=$($(hostname_command)) # default configuration host=localhost port=52698 +eval home=$(builtin printf "~%q" "${SUDO_USER:-$LOGNAME}") function load_config { local rc_file=$1 @@ -76,7 +77,7 @@ function load_config { fi } -for i in "/etc/${0##*/}" ~/."${0##*/}/${0##*/}.rc" ~/."${0##*/}.rc"; do +for i in "/etc/${0##*/}" $home/."${0##*/}/${0##*/}.rc" $home/."${0##*/}.rc"; do load_config $i done