* usr/bin/byobu-launch, usr/bin/byobu-launcher-install: LP: #855002

- ensure that .profile is not sourced more than once
  - ensure that disabled auto launch is respected, too, and does not
    double-source profile
  - handle both system-wide autolaunch, and per-user autolaunch
This commit is contained in:
Dustin Kirkland 2011-09-21 18:29:22 -05:00
commit d2eb104118
3 changed files with 33 additions and 25 deletions

5
debian/changelog vendored
View file

@ -16,6 +16,11 @@ byobu (4.34) unreleased; urgency=low
copy/scrollback mode, but re-enable them afterward; print a
message about Byobu scrollback mode to "eat" the unnecessary
and misleading screen messages when using alt-pgup and alt-pgdown
* usr/bin/byobu-launch, usr/bin/byobu-launcher-install: LP: #855002
- ensure that .profile is not sourced more than once
- ensure that disabled auto launch is respected, too, and does not
double-source profile
- handle both system-wide autolaunch, and per-user autolaunch
-- Dustin Kirkland <kirkland@ubuntu.com> Thu, 08 Sep 2011 14:26:43 -0700

View file

@ -34,31 +34,34 @@ if [ "$BYOBU_SOURCED_PROFILE" != "1" ] && [ "$LC_BYOBU" != "0" ] && [ "$BYOBU_DI
PKG="byobu"
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
. "${BYOBU_PREFIX}/lib/${PKG}/.common"
case "$-" in
*i*)
# Attempt to merge shell history across sessions/windows (works with a few exceptions)
if command -v shopt >/dev/null; then
shopt -s histappend || true
elif command -v setopt >/dev/null; then
# Support zsh too
setopt appendhistory
fi
[ -n "$PROMPT_COMMAND" ] && PROMPT_COMMAND="$PROMPT_COMMAND;history -a" || PROMPT_COMMAND="history -a"
# Source profile
[ -r "$HOME/.profile" ] && . "$HOME/.profile"
if byobu-launcher; then
# Wait very briefly for the no-logout flag to get written?
sleep 0.1
if [ -e "$BYOBU_CONFIG_DIR/no-logout-on-detach" ] || [ -e "$BYOBU_RUN_DIR/no-logout" ]; then
# The user does not want to logout on byobu detach
rm -f "$BYOBU_RUN_DIR/no-logout" # Remove one-time no-logout flag, if it exists
true
else
exit 0
# Ensure that autolaunch is not explicitly disabled
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 command -v shopt >/dev/null; then
shopt -s histappend || true
elif command -v setopt >/dev/null; then
# Support zsh too
setopt appendhistory
fi
fi
;;
esac
[ -n "$PROMPT_COMMAND" ] && PROMPT_COMMAND="$PROMPT_COMMAND;history -a" || PROMPT_COMMAND="history -a"
# Source profile, if necessary
[ -z "$sourced" ] && [ -r "$HOME/.profile" ] && . "$HOME/.profile"
if byobu-launcher; then
# Wait very briefly for the no-logout flag to get written?
sleep 0.1
if [ -e "$BYOBU_CONFIG_DIR/no-logout-on-detach" ] || [ -e "$BYOBU_RUN_DIR/no-logout" ]; then
# The user does not want to logout on byobu detach
rm -f "$BYOBU_RUN_DIR/no-logout" # Remove one-time no-logout flag, if it exists
true
else
exit 0
fi
fi
;;
esac
fi
fi
true
# vi: syntax=sh ts=4 noexpandtab

View file

@ -42,7 +42,7 @@ update_flag() {
}
install_launcher() {
printf ". byobu-launch\n" >> "$1"
printf "sourced=1 . byobu-launch\n" >> "$1"
}
# Sanitize the environment