From 2a59d62e62104b20dad99fa62c60f5c30ee5f5af Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Mon, 12 Jan 2015 17:27:24 -0600 Subject: [PATCH] * debian/rules, usr/bin/byobu.in, usr/bin/byobu-launcher.in, usr/bin/ctail, usr/lib/byobu/include/select-session.py: - silence some checkbashisms false positives - handle nesting a bit differently - allow nesting, by default - detect the infinite loop situation, where we're ssh'ing into ourselves, and handle it gracefully - ensure we have access to 256 colors, even when nesting --- debian/changelog | 9 ++++++++- debian/rules | 2 +- usr/bin/byobu-launcher.in | 11 ++++++++--- usr/bin/byobu.in | 2 +- usr/bin/ctail | 2 +- usr/lib/byobu/include/select-session.py | 18 ------------------ 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4cd7d683..49c88123 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,13 @@ byobu (5.89) unreleased; urgency=medium - * UNRELEASED + * debian/rules, usr/bin/byobu.in, usr/bin/byobu-launcher.in, + usr/bin/ctail, usr/lib/byobu/include/select-session.py: + - silence some checkbashisms false positives + - handle nesting a bit differently + - allow nesting, by default + - detect the infinite loop situation, where we're ssh'ing into + ourselves, and handle it gracefully + - ensure we have access to 256 colors, even when nesting -- Dustin Kirkland Thu, 08 Jan 2015 16:01:27 -0600 diff --git a/debian/rules b/debian/rules index ff8e705b..8bd735cb 100755 --- a/debian/rules +++ b/debian/rules @@ -8,7 +8,7 @@ override_dh_auto_build: # Check shell syntax sh -n `find . -type f -exec grep -l "^\#\!/bin/sh" '{}' \;` # Check for bashisms in shell scripts - checkbashisms `find . -type f -exec grep -l "^\#\!/bin/sh" '{}' \;` || true + checkbashisms `find . -type f -exec grep -l "^\#\!/bin/sh" '{}' \;` 2>&1 | grep "^possible bashism in " | grep -v "sleep only takes one integer" | grep -v "sourced script with arguments" || true dh_auto_build override_dh_perl: diff --git a/usr/bin/byobu-launcher.in b/usr/bin/byobu-launcher.in index 5868b619..8f5af52c 100755 --- a/usr/bin/byobu-launcher.in +++ b/usr/bin/byobu-launcher.in @@ -30,9 +30,14 @@ if [ -O "$HOME" ]; then case "$TERM" in *screen*) # Handle nesting - if [ -n "$LC_BYOBU" ] && [ "$LC_BYOBU" -gt 1 ]; then - # LC_BYOBU > 1, so user explicitly wants nested sessions - exec $BYOBU_PREFIX/bin/byobu "$@" + if [ -n "$LC_BYOBU" ] && [ "$LC_BYOBU" -gt 0 ]; then + # User explicitly wants nested sessions + if [ -n "$SSH_CONNECTION" ] && [ "$(printf "$SSH_CONNECTION" | awk '{print $1}')" != "$(printf "$SSH_CONNECTION" | awk '{print $3}')" ]; then + # Safeguard against ssh-ing into ourself, which causes an infinite loop + exec $BYOBU_PREFIX/bin/byobu "$@" + else + true + fi else true fi diff --git a/usr/bin/byobu.in b/usr/bin/byobu.in index 466e2b90..ee96914b 100755 --- a/usr/bin/byobu.in +++ b/usr/bin/byobu.in @@ -110,7 +110,7 @@ case $BYOBU_BACKEND in tmux) # Use 256 colors if possible if $BYOBU_TEST tput >/dev/null; then - if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ] || [ "$COLORTERM" = "gnome-terminal" ] || [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ]; then + if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ] || [ "$COLORTERM" = "gnome-terminal" ] || [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ] || [ "$TERM" = "screen" ]; then [ -z "$SCREEN_TERM" ] && SCREEN_TERM="-2" fi fi diff --git a/usr/bin/ctail b/usr/bin/ctail index ed95343b..054eef8a 100755 --- a/usr/bin/ctail +++ b/usr/bin/ctail @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -if command -v ccze >/dev/null 2>&1; then +if which ccze >/dev/null 2>&1; then tail -F $@ | ccze -A else echo "ERROR: ccze not found, hint..." 1>&2 diff --git a/usr/lib/byobu/include/select-session.py b/usr/lib/byobu/include/select-session.py index f06b7cba..3f21f0ca 100755 --- a/usr/lib/byobu/include/select-session.py +++ b/usr/lib/byobu/include/select-session.py @@ -102,24 +102,6 @@ def attach_session(session): else: os.execvp("screen", ["", "-AOxRR", session_name]) -# Confirm nested session, if necessary -if os.getenv("BYOBU_NESTING", "0") != "1": - if (BYOBU_BACKEND == "tmux" and os.getenv("TMUX")) or (BYOBU_BACKEND == "screen" and "screen" in os.getenv("TERM")): - sys.stderr.write("WARNING: Sessions should be nested with care.\n") - try: - nest = raw_input("Are you sure you want to run Byobu inside another session? [y/N]: ") - if nest != "Y" and nest != "y": - sys.exit(1) - else: - if os.getenv("TMUX"): - os.unsetenv("TMUX") - except KeyboardInterrupt: - sys.stdout.write("\n") - sys.exit(1) - except: - sys.stdout.write("\n") - sys.exit(1) - sessions = get_sessions() show_shell = os.path.exists("%s/.always-select" % (BYOBU_CONFIG_DIR))