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

Zsh completion with rubber triggers an error message



Hello zsh developers.

First of all, thank you for maintaining such a great piece of software.

My message is to signal an issue that I have been observing for a while but I just took the time to try to understand its cause.

Whenever one tries to complete by pressing `TAB` after `rubber` command in a zsh console, one gets the message "(eval):1: unknown file attribute: 1" that pops up in the middle of the command line.

After investigation, it appears that this error is triggered by the line
  eval $(rubber --version 2>/dev/null | sed 's/^.* \([^ ]*\): */_rubber_\1=/')
from the file `Completion/Unix/Command/_rubber`

Indeed, the string returned by `rubber --version` used to be of the form "Rubber version: X.X.X" but is nowadays "rubber X.X.X" and the current code is too fragile to support both. This change has been introduced upstream (repository https://gitlab.com/latex-rubber/rubber ) with commit 9009066702a2f6ba924b616f8bfbc1bf8e4f6c06 (2018-09-30 | Parse arguments with argparse instead of getopt. [Nicolas Boulenguez]).

A fix is easily set up by changing the `sed` instruction. However, further investigation shows that the zsh completion script is also maintained in rubber's official repository (as file `misc/zsh-completion`) and diverged compared to the version maintained in zsh repository. Indeed, there has been little activity on this file upstream: only two commits (plus one just for renaming) since the upstream commit e84bcbc57f3e6de185cfa9ece325965c0f85dab1 (2005-07-12 | Added module list detection to Zsh completion. [Emmanuel Beffara]) that corresponds to the version initially introduced in zsh repository.

Both commits deserve to be integrated to zsh in my opinion:
  * 7042283e61f1d45ef911d118f63cd8ef11ddbd53 (2018-08-02 | Remove doc for -landscape, disabled by 2893042bd28216047d789295df351c45cbaccb5a [Nicolas Boulenguez]) just updates the list of options supported by rubber.   * Most importantly (with respect to the bug mentioned above), commit 060a48e0e4c58b5d7505d0ce4248e3736f5990e1 (2020-09-29 | Add rubber-lsmod (mostly to be used for zsh completion) [Florian Schmaus]) introduced just one day before the above mentioned commit 9009066702a2f6ba924b616f8bfbc1bf8e4f6c06 changes the whole mechanics used to set up `_rubber_modules`, getting rid of the line `eval ...` that triggers the problem.

The patch to integrate both commits into master on zsh repository follows. Since the change in rubber's repository is based on rubber-lsmod (that seems to have been introduced specifically for this purpose), it won't work with versions of rubber older than about 8 years ago. Would older versions need to be supported, one would have to mix the modern logic together with the previous one where the `sed` expression in the `eval` command would have been made more robust to work both with "Rubber version: X.X.X" and "rubber X.X.X" (also note that some distributions could still add some stuff behind that: for instance on my Fedora 43 system, `rubber --version` reports "rubber 1.6.0 (1.6.0-9-g301dd7e)"). For instance, the following does the trick:
  sed -n 's/^[^0-9]*\([^ ]*\).*/_rubber_version=\1/;p'

I would also recommend the people in charge of this file at zsh to contact the current maintainers of rubber since they do not seem to be aware of the patches introduced in the zsh repository.

Best regards,

Sylvain Chevillard

===================================================

diff --git a/Completion/Unix/Command/_rubber b/Completion/Unix/Command/_rubber
index bd97470dd..b21131e55 100644
--- a/Completion/Unix/Command/_rubber
+++ b/Completion/Unix/Command/_rubber
@@ -1,18 +1,8 @@
 #compdef rubber rubber-pipe rubber-info

-local _rubber_version _rubber_path _rubber_modules _rubber_args
+local _rubber_modules

-eval $(rubber --version 2>/dev/null | sed 's/^.* \([^ ]*\): */_rubber_\1=/')
-if [[ ${_rubber_version#0} != $_rubber_version ]]; then
-  _rubber_modules=(
-    $_rubber_path/rubber/modules/[^_]*.py(N:r:t)
-  )
-else
-  _rubber_modules=(
-    $_rubber_path/modules/*.rub(N:r:t)
-    $_rubber_path/rubber/rules/latex/[^_]*.py(N:r:t)
-  )
-fi
+_rubber_modules=$(rubber-lsmod)

 _rubber_args=(
   \*{-c,--command}'=[run specified directive command before parsing]:command'
@@ -20,7 +10,6 @@ _rubber_args=(
   '(-z --gzip)'{-z,--gzip}'[compress the final document]'
   '(- *)'{-h,--help}'[show help information]'
   '--into=[go to specified directory before compiling]:directory:_files -/' -  '(-l --landscape)'{-l,--landscape}'[change paper orientation (if relevant)]'    '(-n --maxerr)'{-n,--maxerr}'=[display at most specified number of errors]:number'
   \*{-m,--module}'=[use module]:module:($_rubber_modules)'
   '--only=[only include the specified sources]:sources'





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