From 8107b79d6d91531ea7b925cbfa534441f11cccf9 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 2 Nov 2010 21:59:52 -0500 Subject: [PATCH] * usr/bin/byobu-config, usr/bin/byobu-janitor, usr/bin/byobu-launcher- uninstall, usr/share/byobu/keybindings/f-keys: - use gsed, where available; should help with BSD issues running byobu, LP: #651993 --- debian/changelog | 4 ++++ usr/bin/byobu-config | 17 ++++++++++------- usr/bin/byobu-janitor | 13 ++++++++----- usr/bin/byobu-launcher-uninstall | 5 ++++- usr/share/byobu/keybindings/f-keys | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6671c3eb..63aa51cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,10 @@ byobu (3.7) unreleased; urgency=low - allow for disabling the notify_osd status; must handle in the perl script - use BYOBU_PREFIX for local installs + * usr/bin/byobu-config, usr/bin/byobu-janitor, usr/bin/byobu-launcher- + uninstall, usr/share/byobu/keybindings/f-keys: + - use gsed, where available; should help with BSD issues running byobu, + LP: #651993 -- Dustin Kirkland Thu, 21 Oct 2010 12:09:14 -0500 diff --git a/usr/bin/byobu-config b/usr/bin/byobu-config index 31ec7969..2ac5af21 100755 --- a/usr/bin/byobu-config +++ b/usr/bin/byobu-config @@ -52,7 +52,10 @@ RELOAD_CMD="screen -X at 0 source $HOME/."+PKG+"/profile" ESC = '' snack.hotkeys[ESC] = ord(ESC) snack.hotkeys[ord(ESC)] = ESC - +if commands.getstatusoutput('which gsed')[0] == 0: + SED = "gsed" +else: + SED = "sed" gettext.bindtextdomain(PKG, SHARE+'/po') gettext.textdomain(PKG) _ = gettext.gettext @@ -137,7 +140,7 @@ def help(screen, size, config): f.close() text=text.replace("", getesckey(), 1) - text=text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | sed 's/.* //'"), 1) + text=text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | " + SED + " 's/.* //'"), 1) t = Textbox(70, 14, text, scroll=0) bb = ButtonBar(screen, ((_("Menu"), "menu", ESC),), compact = 1) @@ -190,7 +193,7 @@ def keybindings(screen, size): return 100 def switch_keybindings(set): - commands.getoutput("sed -i -e 's:^source .*$:source "+SHARE+"/keybindings/"+set+":' "+HOME+"/."+PKG+"/keybindings") + commands.getoutput(SED + " -i -e 's:^source .*$:source "+SHARE+"/keybindings/"+set+":' "+HOME+"/."+PKG+"/keybindings") def newwindow(screen, size): title=Entry(8, text="shell", returnExit=1) @@ -463,13 +466,13 @@ def setesckey(key): u = key[0].upper() l = key[0].lower() if os.path.exists(path): - out = commands.getoutput("sed -i -e 's/^escape.*$//' "+path) + out = commands.getoutput(SED+" -i -e 's/^escape.*$//' "+path) appendtofile(path, "escape ^"+u+l+"\n") - out = commands.getoutput("sed -i -e 's/^register.*$//' "+path) + out = commands.getoutput(SED+" -i -e 's/^register.*$//' "+path) out = commands.getoutput("grep -h ^register "+SHARE+"/keybindings/*keys") appendtofile(path, out+"\n") - out = commands.getoutput("sed -i -e 's/\"\^a/\"\^"+l+"/g' "+path) - out = commands.getoutput("sed -i -e '/^$/d' "+path) + out = commands.getoutput(SED+" -i -e 's/\"\^a/\"\^"+l+"/g' "+path) + out = commands.getoutput(SED+" -i -e '/^$/d' "+path) def chgesc(screen, size): esc=Entry(2, text=getesckey(), returnExit=1) diff --git a/usr/bin/byobu-janitor b/usr/bin/byobu-janitor index aba21f7e..0d52ca20 100755 --- a/usr/bin/byobu-janitor +++ b/usr/bin/byobu-janitor @@ -25,6 +25,9 @@ PKG="byobu" RUN="$SOCKETDIR/S-$USER" FLAG="$RUN/$PKG.reload-required" +# Use gsed on non-Linux OS's +which gsed 2>/dev/null && SED="gsed" || SED="sed" + # Exit immediately, if we're not forced, and there is no reload flag if [ "$1" != "--force" ] && [ ! -e "$FLAG" ]; then exit 0 @@ -111,9 +114,9 @@ fi # The status scripts used to have hyphens in their name, but now use # underscores such that we can source the file as a shell snippet; # fix existing status configuration. -sed -i -e "s/\([^=]+\)-\([^=]+\)=/\1_\2=/g" "$HOME/.$PKG/status" -sed -i -e "s/^disk-.*=/disk=/" "$HOME/.$PKG/status" -sed -i -e "s/^network-.*=/network=/" "$HOME/.$PKG/status" +$SED -i -e "s/\([^=]+\)-\([^=]+\)=/\1_\2=/g" "$HOME/.$PKG/status" +$SED -i -e "s/^disk-.*=/disk=/" "$HOME/.$PKG/status" +$SED -i -e "s/^network-.*=/network=/" "$HOME/.$PKG/status" # Affects: Upgrades from <= byobu-2.16 # screen-launcher was renamed byobu-launcher; if the user has byobu @@ -142,7 +145,7 @@ done # Affects: Upgrades from <= byobu-2.57 that autolaunch # If the global autolaunch is on, then remove duplicate entry in ~/.profile if [ -h "/etc/profile.d/Z98-$PKG.sh" ]; then - sed -i -e "/ $PKG-launcher/d" "$HOME"/.profile || true + $SED -i -e "/ $PKG-launcher/d" "$HOME"/.profile || true fi # Affects: Upgrades from <= byobu-2.70 that autolaunch @@ -154,7 +157,7 @@ fi # Affects: Upgrades from <= byobu-2.78 which might have "motd+shell" # in their window list; update this to just "shell" if grep -qs "motd+shell" "$HOME/.$PKG/windows"; then - sed -i -e "s/motd+shell/shell/g" "$HOME/.$PKG/windows" || true + $SED -i -e "s/motd+shell/shell/g" "$HOME/.$PKG/windows" || true fi # Clean up flag diff --git a/usr/bin/byobu-launcher-uninstall b/usr/bin/byobu-launcher-uninstall index 7701c943..14ffe13c 100755 --- a/usr/bin/byobu-launcher-uninstall +++ b/usr/bin/byobu-launcher-uninstall @@ -20,10 +20,13 @@ PKG="byobu" +# Use gsed on non-Linux OS's +which gsed 2>/dev/null && SED="gsed" || SED="sed" + remove_launcher() { dest=$1 if [ -w "$dest" ]; then - sed -i -e "/ $PKG-launcher/d" -e "/ screen-launcher/d" "$dest" + $SED -i -e "/ $PKG-launcher/d" -e "/ screen-launcher/d" "$dest" fi } diff --git a/usr/share/byobu/keybindings/f-keys b/usr/share/byobu/keybindings/f-keys index 5db374b7..9a8539d6 100644 --- a/usr/share/byobu/keybindings/f-keys +++ b/usr/share/byobu/keybindings/f-keys @@ -39,7 +39,7 @@ bind $ screen -t status 0 byobu-status-detail # ctrl-a $ | show detailed statu bind @ screen -t config 0 byobu-config # ctrl-a @ | Configuration bind R process r # ctrl-a R | Reload profile register s "^a[g G$>^h" # Goes with ^a~ definition -bind ~ eval 'process s' 'exec sed -i -e "/./,/^$/!d" /var/run/screen/S-$USER/byobu-exchange' 'echo "See: /var/run/screen/S-$USER/byobu-exchange"' # ctrl-a ~ | write the buffer to file +bind ~ eval 'process s' 'exec $(which gsed || printf sed) -i -e "/./,/^$/!d" /var/run/screen/S-$USER/byobu-exchange' 'echo "See: /var/run/screen/S-$USER/byobu-exchange"' # ctrl-a ~ | write the buffer to file # toggle f-key keybindings off register d "^a:source $BYOBU_PREFIX/share/byobu/keybindings/screen-escape-keys^M"