Skip to content

Commit

Permalink
resolve origin user when using rmate with sudo
Browse files Browse the repository at this point in the history
to fix the problem that a config-file could not be loaded from ~ of origin user if rmate is executed using sudo
  • Loading branch information
aurora committed Apr 14, 2016
1 parent a7f3fed commit 0d86249
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rmate
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 0d86249

Please sign in to comment.