From e61991992717d425d78d00fa583d7a9e2c20003b Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 7 Feb 2013 14:46:56 -0600 Subject: [PATCH] * debian/rules, usr/bin/byobu, usr/bin/byobu-launch, usr/lib/byobu/include/common, usr/lib/byobu/include/constants: - clean up some bashisms (better portability) - checkbashisms at build time --- debian/changelog | 4 ++++ debian/rules | 2 ++ usr/bin/byobu | 11 ++++++----- usr/bin/byobu-launch | 16 +++++++++------- usr/lib/byobu/include/common | 10 +++------- usr/lib/byobu/include/constants | 3 +++ 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0b3a4d16..9882e16f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,10 @@ byobu (5.32) unreleased; urgency=low * usr/lib/byobu/mail: LP: #1118364 - support maildir format + * debian/rules, usr/bin/byobu, usr/bin/byobu-launch, + usr/lib/byobu/include/common, usr/lib/byobu/include/constants: + - clean up some bashisms (better portability) + - checkbashisms at build time -- Dustin Kirkland Wed, 06 Feb 2013 23:16:22 -0600 diff --git a/debian/rules b/debian/rules index ae3b3d30..999b79bc 100755 --- a/debian/rules +++ b/debian/rules @@ -5,6 +5,8 @@ override_dh_auto_build: # Check syntax pep8 --verbose --repeat --ignore W191,E501 usr/bin/byobu-config usr/bin/byobu-select-session + # Check for bashisms in shell scripts + checkbashisms `find . -type f -exec grep -l "^\#\!/bin/sh" '{}' \;` dh_auto_build override_dh_perl: diff --git a/usr/bin/byobu b/usr/bin/byobu index 74925bf7..26635aeb 100755 --- a/usr/bin/byobu +++ b/usr/bin/byobu @@ -64,11 +64,12 @@ if [ "$#" = "1" ]; then case "$1" in -v|--version) echo "$PKG version $VERSION" + if [ -n "$BYOBU_ULIMIT" ]; then + # Check ulimits + [ $($BYOBU_ULIMIT -n) -ge 15 ] || echo "WARNING: ulimit -n is too low" 1>&2 + [ $($BYOBU_ULIMIT -u) -ge 1600 ] || echo "WARNING: ulimit -u is too low" 1>&2 + fi exec $BYOBU_BACKEND $BYOBU_ARG_VERSION - # Check ulimits - [ $(ulimit -n) -ge 15 ] || echo "WARNING: ulimit -n is too low" 1>&2 - [ $(ulimit -u) -ge 1600 ] || echo "WARNING: ulimit -u is too low" 1>&2 - exit 0 ;; esac @@ -85,7 +86,7 @@ byobu-janitor --force # Set the window title [ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc" . $BYOBU_PREFIX/lib/$PKG/ip_address -[ -n "$BYOBU_NO_TITLE" ] || printf "\033]0;${USER}@${HOSTNAME:-$(hostname)} ($(__ip_address t)) - ${PKG}\007" +[ -n "$BYOBU_NO_TITLE" ] || printf "\033]0;${USER}@$(hostname) ($(__ip_address t)) - ${PKG}\007" # Drop a symlink to the ssh socket in $HOME, since we can ensure that exists if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then diff --git a/usr/bin/byobu-launch b/usr/bin/byobu-launch index 0ea19d8f..369dd56d 100755 --- a/usr/bin/byobu-launch +++ b/usr/bin/byobu-launch @@ -49,13 +49,15 @@ elif [ "$BYOBU_SOURCED_PROFILE" != "1" ] && [ "$LC_BYOBU" != "0" ] && [ "$BYOBU_ if [ ! -r "$BYOBU_CONFIG_DIR/disable-autolaunch" ]; then case "$-" in *i*) - # Attempt to merge shell history across sessions/windows (works with a few exceptions) - if $BYOBU_TEST shopt >/dev/null; then - shopt -s histappend || true - elif $BYOBU_TEST setopt >/dev/null; then - # Support zsh too - setopt appendhistory - fi + # Attempt to merge shell history across sessions/windows (works with some exceptions) + for i in shopt setopt; do + if $BYOBU_TEST $i >/dev/null; + case $i in + shopt) $i -s histappend || true ;; + setopt) $i appendhistory || true ;; + esac + fi + done [ -n "$PROMPT_COMMAND" ] && PROMPT_COMMAND="$PROMPT_COMMAND;history -a;history -r" || PROMPT_COMMAND="history -a;history -r" # Source profile, if necessary [ -z "$_byobu_sourced" ] && [ -r "$HOME/.profile" ] && . "$HOME/.profile" diff --git a/usr/lib/byobu/include/common b/usr/lib/byobu/include/common index 90c255fb..08352195 100755 --- a/usr/lib/byobu/include/common +++ b/usr/lib/byobu/include/common @@ -23,13 +23,9 @@ if [ -z "${BYOBU_INCLUDED_LIBS}" ]; then . "${BYOBU_PREFIX}/lib/${PKG}/include/dirs" # Find command/type/which - if command -v 2>/dev/null; then - BYOBU_TEST="command -v" - elif type 2>/dev/null; then - BYOBU_TEST="type" - else - BYOBU_TEST="which" - fi + for BYOBU_TEST in "command -v" "type" "which"; do + $BYOBU_TEST >/dev/null && break + done # If the backend is already set (eg. running `byobu-tmux`), do nothing. if [ -z "${BYOBU_BACKEND}" ]; then diff --git a/usr/lib/byobu/include/constants b/usr/lib/byobu/include/constants index 5944e4a5..13261c27 100755 --- a/usr/lib/byobu/include/constants +++ b/usr/lib/byobu/include/constants @@ -101,6 +101,9 @@ $BYOBU_TEST sensible-pager >/dev/null 2>&1 && export BYOBU_PAGER="sensible-pager # Check sed's follow-symlinks feature $BYOBU_SED --follow-symlinks "s///" /dev/null && BYOBU_SED="$BYOBU_SED --follow-symlinks" || true +# Determine if we have ulimit support +$BYOBU_TEST ulimit >/dev/null 2>&1 && export BYOBU_ULIMIT="ulimit" || export BYOBU_ULIMIT= + # Default colors export BYOBU_DARK="black" export BYOBU_LIGHT="white"