From b6fb57f94f859e748ee26fcccca9535dedf6dc88 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:09:25 +0800 Subject: [PATCH] * usr/bin/byobu-disable-prompt.in, usr/bin/byobu-janitor.in: - Test if $HOME/.bashrc exists before modifying it (and potentially creating it) --- debian/changelog | 4 ++++ usr/bin/byobu-disable-prompt.in | 2 ++ usr/bin/byobu-janitor.in | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a78a8b15..3daff1c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,10 @@ byobu (5.128) unreleased; urgency=medium - https://github.com/dustinkirkland/byobu/pull/30 [ Jeffery To ] + * usr/bin/byobu-disable-prompt.in, + usr/bin/byobu-janitor.in: + - Test if $HOME/.bashrc exists before modifying it (and potentially + creating it) * usr/lib/byobu/logo: - Add logo for OpenWrt diff --git a/usr/bin/byobu-disable-prompt.in b/usr/bin/byobu-disable-prompt.in index 59b5e0e7..2e3946db 100755 --- a/usr/bin/byobu-disable-prompt.in +++ b/usr/bin/byobu-disable-prompt.in @@ -22,6 +22,8 @@ PKG="byobu" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="@prefix@" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" +[ -w "$HOME/.bashrc" ] || exit 1 + $BYOBU_SED_INLINE -e "/#byobu-prompt#$/d" "$HOME/.bashrc" if [ "$1" != "--no-reload" ]; then diff --git a/usr/bin/byobu-janitor.in b/usr/bin/byobu-janitor.in index 38ddebe8..071b82ca 100755 --- a/usr/bin/byobu-janitor.in +++ b/usr/bin/byobu-janitor.in @@ -112,7 +112,8 @@ killall -u $USER byobu-statusd >/dev/null 2>&1 || true rm -f "$FLAG" "/var/run/screen/S-$USER/$PKG.reload-required" # Affects: Upgrades from <= byobu 5.50, install byobu prompt if using stock bashrc -if ! (grep -qs "#byobu-prompt#$" "$HOME/.bashrc") && ! [ -e "$BYOBU_CONFIG_DIR/prompt" ]; then +if [ -r /etc/skel/.bashrc ] && [ -r "$HOME/.bashrc" ] && [ -w "$HOME/.bashrc" ] && \ + ! (grep -qs "#byobu-prompt#$" "$HOME/.bashrc") && ! [ -e "$BYOBU_CONFIG_DIR/prompt" ]; then if eval $BYOBU_TEST diff >/dev/null 2>&1; then if diff /etc/skel/.bashrc "$HOME/.bashrc" >/dev/null 2>&1; then printf "[ -r $BYOBU_CONFIG_DIR/prompt ] && . $BYOBU_CONFIG_DIR/prompt #byobu-prompt#\n" >> "$HOME/.bashrc"