bash - Why does "24 > 10#24" generate an error token? -


I have a function workcom that compares two version string and determines that Which is big when I add this surname: <<> alias grep = 'grep -ei --colour = always'

My appears to be unrelated part Bashrc file I get this error:

  -bash: 10 # 24> 10 # 24: Syntax error: invalid arithmetic operator (error token "24> 10 # 24 ") -bash: 10 # 24 & lt; 10 # 24: Syntax Error: Invalid arithmetic operator (error token "24 <10 # 24")   

Note that the error is emitted twice, I'm assuming because the error Has processed twice (ie this is not typo on my part). Note that when I remove the alias, everything works fine, why it works and how can I reduce it?

Lines of interest, below, are probably marked:

  if ((10 # $ {ver1 [i]} & gt; 10 # $ {ver2 [i]})); Then return to 1f ((# 10 $ $ {ver1 [i]} & lt; 10 # $ {ver2 [i]})); Then 2fi   

Edit: Add more context

I use GNU bash, version 3.2.48 (1) -release () I'm doing x86_64-apple-darwin11) on Mac OS X 10.7.5 (Lion). I'm calling workcom this way:

  if [[OS $ = 'Mac']]; Then ### EMACS version check # Make sure we are working with EMACS; = 24 wanted_ver = 24 curr_ver = `emacs --version | Grep -oE '[[Issue:]] + \. [. [: Points:]] * '`$ curr_ver vercomp $ curr_ver $ wanted_ver   

Note that I'm calling curr_ver to start < Code> grep I still can not understand why the error is happening, but an error does not occur by using grep -EI --color , so that my question Can anyone get an answer for the second part? Does anyone know why why is an error?


  vercomp () {## returns: 0 equals ## 1 ver1 & gt; See 2 ## 2 years 1 and lieutenant; See 2 if [[$ 1 == $ 2]]; Then back to the IFS # IFS (Internal Field Separator) field a '.' # ($ var) Notation means to convert $ var to array according to IAFS. Fill in the local IFS = local i ver1 = ($ 1) ver2 = ($ 2) # zero in the empty field with the number of elements in zero # $ {# var [@]} = array / var. For ((i = $ {# ver1 [@]}; i & lt; $ {# ver2 [@]}; i ++)); (I = 0; i & lt; $ {# ver1 [@]}; i ++) ver1 [i] = 0; What to do [[-z $ {ver2 [i]}]]; Then fill in the # zero zero field with 2 zeros [i] = 0 fi # & lt; Num & gt; The value of # $ var $ var & lt; Num & gt; If ((10 # $ {ver1 [i]} & gt; 10 # $ {ver2 [i]})); Then return to 1f ((# 10 $ $ {ver1 [i]} & lt; 10 # $ {ver2 [i]})); Then return the 2fi return.   

aliased grep of two variables To make any production you are going through the workstation , you will almost certainly know that the output sequence is in your output output.

This is because you were clearly told told according to grep man page to do this with - color = all / em> grep / P>

- Color [= WHEN] : Matched (non-empty) string, mailing line, reference lines, File name, line number, byte offset, and

If you prefer the code it should become clear:

  echo "$ 1" | Od -xcb "$ 2" echo Od -xcb   

At the beginning of your workstation function, in that case the escape sequence should be easily detected.

In fact, if I execute the following code in a script that contains your vercomp function:

  curr_ver = $ (echo) 21.7 | grep -EI --color = always '^ ..') echo "$ curr_ver" | Od-xcb vercomp $ curr_ver 21.5   

Output is:

  0000000 5b1b 3130 333b 6d31 5b1b 324b 1b31 6d5b 033 [0 1; 3 1 m 033 [K 2 0 033 [M 033 133 060 061 073 063 061 155 033 133 113 062 061 033 133 155 0000020 5 B1 B2E 4 B A 37333 [K. 7 \ n 033 133 113 056 067 0012 0000026 ./qq.bash: Line 30: 10 # 21 & gt; 10 # 21: Syntax Error: Invalid arithmetic operator (error token "21 & gt; 10 # 21") ./qq.bash: Line 33: 10 # 21 & lt; 10 # 21: Syntax Error: Invalid arithmetic operator (error token "21 & lt; 10 # 21")   

So you can see both:

  • Output contains escape sequences to give color to your foundations; And
  • You can generate similar errors from what you see.

    If you get rid of the color (even if it is temporarily too), then you should make the errors disappear. / P>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -