zsh: include/common needs sh_word_split option: "command not found: command -v"

Bug #1180427 reported by Daniel Hahler on 2013-05-15
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
byobu
Medium
Unassigned

Bug Description

When sourcing byobu-reconnect-sockets there is an error when zsh is used as the shell.

    byobu/usr/lib/byobu/include/common:27: command not found: command -v

The following change causes the error:

revno: 2067
committer: Dustin Kirkland <email address hidden>
branch nick: byobu
timestamp: Thu 2013-02-07 14:46:56 -0600
message:
  * 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
diff:
=== modified file 'usr/lib/byobu/include/common'
--- usr/lib/byobu/include/common 2013-01-19 19:49:52 +0000
+++ usr/lib/byobu/include/common 2013-02-07 20:46:56 +0000
@@ -23,13 +23,9 @@
        . "${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

Previously the error only happened when $BYOBU_TEST was actually used.

What do you think about using a function instead of a variable (and pass the command to be run as argument(s))?
This could then wrap the "setopt" needed for zsh, which is already used with tmux_update and screen_update:

    [ "x$ZSH_VERSION" != x ] && setopt local_options sh_word_split

This is with byobu r2123.

Keith Hughitt (keith-hughitt) wrote :

Confirmed in byobu 5.35 + ZSH 5.0.2.

Changed in byobu:
importance: Undecided → Medium
status: New → In Progress
Dustin Kirkland  (kirkland) wrote :

Committed revision 2145.

Changed in byobu:
status: In Progress → Fix Committed
Changed in byobu:
status: Fix Committed → Fix Released
Daniel Hahler (blueyed) wrote :

Re-opening: STDERR needs to be redirected to make this "hack" work properly.
It makes sense to redirect both STDERR and STDOUT here anyway.

I would still suggest to have a more central method, where the sh_word_split option would get set for zsh.

Changed in byobu:
status: Fix Released → Triaged
Dustin Kirkland  (kirkland) wrote :

Committed revision 2158.

Changed in byobu:
status: Triaged → Fix Committed
Changed in byobu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers