From e537a69098545122d262fa584d11f11ed39588a7 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:15:56 +0800 Subject: [PATCH] * usr/lib/byobu/whoami: - Use id if the whoami command is not available - Read from /etc/passwd if the getent command is not available --- debian/changelog | 3 +++ usr/lib/byobu/whoami | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 31b1104f..26682ee4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,9 @@ byobu (5.128) unreleased; urgency=medium - Fix reading services from $BYOBU_CONFIG_DIR/statusrc * usr/lib/byobu/updates_available: - Add support for opkg (OpenWrt) + * usr/lib/byobu/whoami: + - Use id if the whoami command is not available + - Read from /etc/passwd if the getent command is not available * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/whoami b/usr/lib/byobu/whoami index 93a6702f..f3c4f26b 100755 --- a/usr/lib/byobu/whoami +++ b/usr/lib/byobu/whoami @@ -19,12 +19,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +___get_user() { + if eval $BYOBU_TEST whoami >/dev/null 2>&1; then + whoami + elif eval $BYOBU_TEST id >/dev/null 2>&1; then + id -un + fi +} + __whoami_detail() { - getent -- passwd "$USER" + local user=$(___get_user) + [ -n "$user" ] || return + if eval $BYOBU_TEST getent >/dev/null 2>&1; then + getent -- passwd "$user" + else + grep "^$user:" /etc/passwd + fi } __whoami() { - color bold2; printf "%s@" "$(whoami)"; color - + local user=$(___get_user) + [ -n "$user" ] || return + color bold2; printf "%s@" "$user"; color - } # vi: syntax=sh ts=4 noexpandtab