Skip to content

Request: broot --send NONEXISTENT-SOCKET ... to yield a non-zero exit code #1069

@AndydeCleyre

Description

@AndydeCleyre
$ broot --send asdlfkasdjfaskldf -c ':focus /home'
error on the socket: No such file or directory (os error 2)

Currently this yields an exit code 0. I request that this be changed to any non-zero exit code, to better reflect a failure condition, when used in a scripting context.

Currently:

$ broot --send asdlfkasdjfaskldf -c ':focus /home' && echo "great success"
error on the socket: No such file or directory (os error 2)
great success

I think this is reasonable on general principle, but my very specific use case is a Zsh function which opens a broot view in an unfocused tmux "side pane." A hook is added to the shell environment so that the broot instance changes directory to match the main pane. If I later close that broot instance, I want to remove the hook.

I thought the simplest method to do so might be to have the hook function remove itself if the broot --send command ever fails:

# -- Pinned view in another tmux pane --
broot-pin () {
  emulate -L zsh
  local name=$RANDOM

  eval '
    update_pinned_broot_$name () {
      if ! { broot --send '$name' -c ":focus $PWD" 2>/dev/null } {
        add-zsh-hook -d precmd $0
        unfunction gob
      }
    }

    gob () {
      emulate -L zsh
      cd "$(broot --send '$name' --get-root)"
    }
  '

  add-zsh-hook precmd update_pinned_broot_$name
  tmux splitw -d -h -l 70 broot --listen $name
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions