Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zsh function breaks after error

I have googled for what seems to be an simple and obvious thing but
somehow I seem to be unable to find what I'm looking for. So here goes.

I have this function, called via keyboard shortcut while editing a line:

expandDir2() {
	zle backward-kill-word
	local _dir=$CUTBUFFER
	_dir=$(command grep -hP "$_dir" ~/other/dirlist_*.txt | rofi -dmenu -p
  echo Never reached on Esc.
	[[ "$_dir" == "" ]] && BUFFER=$BUFFER$CUTBUFFER || BUFFER=$BUFFER$_dir

This basically reads a search string (say "u*sh*z"), greps a set of
files with directory lists (created by a custom script) and runs rofi in
dmenu mode to select one directory which then replaces the search
string. This works very well. The trouble starts when rofi is terminated
not via selecting one of the shown directories (exit value 0) but with
Esc/Ctrl-G (exit value 1).

In this case the function just breaks and I have found no way to
actually check for either the returned string of rofi or its exit value.
Bash has set +-e and I am sure there is sth similar for zsh but I can't
for the life of me find it (I have for now "solved" the problem by
writing a two-liner that calls rofi and always returns exit 0 but that's
a kludge at best).


Messages sorted by: Reverse Date, Date, Thread, Author