zsh-users
 help / color / mirror / code / Atom feed
* zsh function breaks after error
@ 2022-02-08 17:16 Thomas Lauer
  2022-02-09 15:18 ` Bart Schaefer
  0 siblings, 1 reply; 20+ messages in thread
From: Thomas Lauer @ 2022-02-08 17:16 UTC (permalink / raw)
  To: Zsh Users

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=${_dir:gs/*/.+/}
	_dir=${_dir:gs/?/./}
	_dir=${_dir:gs/:/(?i)/}
	_dir=$(command grep -hP "$_dir" ~/other/dirlist_*.txt | rofi -dmenu -p
\"Directory\")
  echo Never reached on Esc.
	[[ "$_dir" == "" ]] && BUFFER=$BUFFER$CUTBUFFER || BUFFER=$BUFFER$_dir
	CURSOR=$#BUFFER
}

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).

THX Tom


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-02-22  4:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 17:16 zsh function breaks after error Thomas Lauer
2022-02-09 15:18 ` Bart Schaefer
2022-02-09 18:45   ` Thomas Lauer
2022-02-09 20:16     ` Bart Schaefer
2022-02-10 13:55       ` Thomas Lauer
2022-02-10 13:59         ` Roman Perepelitsa
2022-02-10 16:20           ` Thomas Lauer
2022-02-10 16:48             ` Roman Perepelitsa
2022-02-10 17:20               ` Thomas Lauer
2022-02-10 21:26                 ` Ray Andrews
2022-02-10 21:45                   ` Thomas Paulsen
2022-02-10 23:37                     ` Daniel Shahaf
2022-02-11 15:07                     ` Thomas Lauer
2022-02-11 14:58                   ` Thomas Lauer
2022-02-11 15:59                     ` Ray Andrews
2022-02-11 23:31                       ` Bart Schaefer
2022-02-12  3:39                         ` Ray Andrews
2022-02-22  3:58                         ` Matthew Martin
2022-02-12 16:45                       ` Thomas Lauer
2022-02-12 17:48                         ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).