diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-06 07:38:23 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-06 08:28:53 -0700 |
commit | d317674a62e8301771394e2b43eb5e50f929100c (patch) | |
tree | 4f1dfe066dc451ca8e6c2cbd6db3d0b06783c93d /lib-src | |
parent | 5286bd22a72333c4215cce0ea7cdaa2f567ff16c (diff) | |
download | dotfiles-d317674a62e8301771394e2b43eb5e50f929100c.tar.gz |
myrepos config: improve obtaining username and hostname
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/mr/config | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib-src/mr/config b/lib-src/mr/config index f49febb6..dd9efe12 100644 --- a/lib-src/mr/config +++ b/lib-src/mr/config @@ -41,16 +41,21 @@ git_update = git pull-safe # --- tests, plus my code for detecting Git-on-Windows lib = + if [ -n "$USER" ]; then + whoami="$USER" + elif [ -n "$LOGNAME" ]; then + whoami="$LOGNAME" + else + # Cut off any Windows machine name. + whoami="$(whoami)"; whoami="${whoami##*\\}" + fi + # Ensure it's a short hostname, not an FQDN. + hostname="$(hostname)"; hostname="${hostname%%.*}" + # win32() { test "$(perl -e 'print $^O')" = "msys" } # - hostname="$(hostname | sed -e 's#\..*$##')" - # - whoami="$(whoami)" - # cut off the machine name on Windows - win32 && whoami=${whoami##*\\} - # on() { for host in $@; do if [ "${host%@*}" != "${host#*@}" ]; then |