Skip to content

Commit 0d86249

Browse files
committed
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
1 parent a7f3fed commit 0d86249

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rmate

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ hostname=$($(hostname_command))
5757
# default configuration
5858
host=localhost
5959
port=52698
60+
eval home=$(builtin printf "~%q" "${SUDO_USER:-$LOGNAME}")
6061

6162
function load_config {
6263
local rc_file=$1
@@ -76,7 +77,7 @@ function load_config {
7677
fi
7778
}
7879

79-
for i in "/etc/${0##*/}" ~/."${0##*/}/${0##*/}.rc" ~/."${0##*/}.rc"; do
80+
for i in "/etc/${0##*/}" $home/."${0##*/}/${0##*/}.rc" $home/."${0##*/}.rc"; do
8081
load_config $i
8182
done
8283

0 commit comments

Comments
 (0)