hchbaw/auto-fu.zsh

random error

Closed this issue · 4 comments

joe9 commented

Hello,

I receive this random error once in a while.

afu-rhs-protect:15: bad math expression: operand expected at > 0 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 0'
afu-rhs-protect:21: bad math expression: operator expected at 1 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at1 standout...'
--(/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)--
c
afu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'
afu-rhs-protect:21: bad math expression: operator expected at 1 underlin...' afu-rhs-protect:15: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 1' afu-rhs-protect:21: bad math expression: operator expected at2 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 1'
afu-rhs-protect:21: bad math expression: operator expected at none > 1 +...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at1 underlin...'
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 2 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected atnone > 2 +...'
--(
/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)--
cd
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at 2 fg=green...' afu-rhs-protect:15: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 2' afu-rhs-protect:21: bad math expression: operator expected at3 standout...'
afu-rhs-protect:15: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 2'
afu-rhs-protect:21: bad math expression: operator expected at none > 2 +...' --(~/etc/trapd00r_configs)---------------------------------------------------------------------------------------------------(pts/20@master)-- cd afu-rhs-protect:15: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 3' afu-rhs-protect:21: bad math expression: operator expected at2 fg=green...'
afu-rhs-protect:15: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 3'
afu-rhs-protect:21: bad math expression: operator expected at 4 standout...' afu-rhs-protect:15: bad math expression: operand expected at> 4 + 1'
afu-rhs-protect:18: bad math expression: operand expected at > 4' afu-rhs-protect:21: bad math expression: operator expected at2 fg=green...'
afu-rhs-protect:15: bad math expression: operand expected at > 4 + 1' afu-rhs-protect:18: bad math expression: operand expected at> 4'
afu-rhs-protect:21: bad math expression: operator expected at `4 standout...'

Any thoughts, please?

Thanks
Joe

Hi, Joe! Thank you for your report.

Sorry, I have not seen this before…
How about this patch? (This is mostly guesswork though)

diff --git a/auto-fu.zsh b/auto-fu.zsh
index 163603b..01c00ac 100644
--- a/auto-fu.zsh
+++ b/auto-fu.zsh
@@ -739,6 +739,9 @@ afu-rhs-protect () {
   local rillfun="$4"
   shift 4
   local -a a; : ${(A)a::=$@}
+  if (($#a == 0)) || (($#a == 1)) && [[ -z "$a" ]]; then
+    return -1
+  fi
   if [[ -n "$RBUFFER" ]]; then
     if ((CURSOR > $tmp[2])) || [[ $WIDGET == *complete* ]]; then
       "$savefun" "$a[*]"
joe9 commented

Hello Takeshi,

Thanks for the patch. I applied it. Can you please add this patch to the pu
branch? The gentoo build uses that branch and I do not want to lose the
patch if I reinstall.

diff --git a/auto-fu.zsh b/auto-fu.zshindex 163603b..01c00ac 100644---
a/auto-fu.zsh+++ b/auto-fu.zsh@@ -739,6 +739,9 @@ afu-rhs-protect () {
local rillfun="$4"
shift 4
local -a a; : ${(A)a::=$@}+ if (($#a == 0)) || (($#a == 1)) && [[
-z "$a" ]]; then+ return -1+ fi
if [[ -n "$RBUFFER" ]]; then
if ((CURSOR > $tmp[2])) || [[ $WIDGET == complete ]]; then
"$savefun" "$a[*]"

Thanks
Joe

joe9 commented

Hello Takeshi,

still happening, it seems.

--()------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)--
etc/zsh/
etc/zsh/
compdef/ 01-prezto-helper.zsh@ 20-bookmarks.zsh
40-alias-suffix.zsh 50-bindkeys.zsh 90-syntax.zsh@
all_opts history_words_to_commands.patch
trapd00r.theme zprofile.root
compdef.disable/ 05-appearance.unused_zsh 20-exports.zsh
40-alias.zsh 50-functions.zsh
90-syntax.zsh.zsh-syntax-highlighting all_opts_bang
mikachu-dot-zshrc zprofile.20110925 zprofile.simple
prezto/ 06-zex.zsh-does-not-work@ 20-history.zsh
40-completion.zsh 60-git.zsh
91-history-substring-search.zsh bart.theme
start-zsh-with-cmd.exp* zprofile.20120319 zsh_history.joe
zex-zsh/ 10-syntax.zsh.trapd00r 20-setopts.zsh
40-completion.zsh.original 70-autojump.zsh 92-auto-fu.zsh
colorize* todo
zprofile.20130124 zshrc
01-colors.zsh 20-abbrevations.zsh 40-alias-global.zsh
40-directory.zsh@ 70-simpleprompt.zsh 99-startup.zsh
colorize.c todo.txt
zprofile.latest@
/home/j/etc/zsh/zsh_history.joe
1180 28.2.2013 02:00 g age *
1181 28.2.2013 02:00 gi age *
1182 28.2.2013 02:00 gi age *.zsh
1183 28.2.2013 02:00 which age
1184 28.2.2013 02:00 x
--(
/etc/zsh)----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)--
which age
which age
age () {
# undefined
builtin autoload -XUz
}
age is a shell function
age:
a: ERROR: cannot open a' (No such file or directory) --(~/etc/zsh)----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)-- m afu-rhs-protect:18: bad math expression: operand expected at> 1 + 1'
afu-rhs-protect:21: bad math expression: operand expected at > 1' afu-rhs-protect:24: bad math expression: operator expected at1 fg=green...'
afu-rhs-protect:18: bad math expression: operand expected at > 1 + 1' afu-rhs-protect:21: bad math expression: operand expected at> 1'
afu-rhs-protect:24: bad math expression: operator expected at none > 1 +...' afu-rhs-protect:18: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:21: bad math expression: operand expected at > 2' afu-rhs-protect:24: bad math expression: operator expected at1 fg=green...'
afu-rhs-protect:18: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:21: bad math expression: operand expected at> 2'
afu-rhs-protect:24: bad math expression: operator expected at none > 2 +...' --(~/etc/zsh)----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)-- ma afu-rhs-protect:18: bad math expression: operand expected at> 2 + 1'
afu-rhs-protect:21: bad math expression: operand expected at > 2' afu-rhs-protect:24: bad math expression: operator expected at1 fg=green...'
afu-rhs-protect:18: bad math expression: operand expected at > 2 + 1' afu-rhs-protect:21: bad math expression: operand expected at> 2'
afu-rhs-protect:24: bad math expression: operator expected at none > 2 +...' afu-rhs-protect:18: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:21: bad math expression: operand expected at > 3' afu-rhs-protect:24: bad math expression: operator expected at1 fg=green...'
afu-rhs-protect:18: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:21: bad math expression: operand expected at> 3'
afu-rhs-protect:24: bad math expression: operator expected at none > 3 +...' --(~/etc/zsh)----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)-- man afu-rhs-protect:18: bad math expression: operand expected at> 3 + 1'
afu-rhs-protect:21: bad math expression: operand expected at > 3' afu-rhs-protect:24: bad math expression: operator expected at1 fg=green...'
afu-rhs-protect:18: bad math expression: operand expected at > 3 + 1' afu-rhs-protect:21: bad math expression: operand expected at> 3'
afu-rhs-protect:24: bad math expression: operator expected at `none > 3 +...'
--(~/etc/zsh)----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------(pts/18@master)--
man

This is the definition of my which command:

which
which () {
IFS="$(printf '\n\t')"
printf '\e[?7t'
builtin which "$@" && builtin type "$@" && whereis "$@" &&
file $(builtin type "$@" | awk '{print $3}') 2> /dev/null
printf '\e[?7t'
}
which is a shell function
which: /usr/bin/which /usr/share/man/man1/which.1.bz2
a: ERROR: cannot open `a' (No such file or directory)

Please let me know if you need more details.

Thanks
Joe

Hi, Joe! Thank you for reporting back!

I can reproduce the error now; the $IFS is the cause.
I change the which function's IFS="$(print '\n\t')" to local IFS=… then this problem goes away.

Some auto-fu's codes are depending on IFS value :(
I will fix this for some time.

For now, please handle it with editing which function's definition.
Sorry for the inconvenience.