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

Re: Are there "binary" variables?



On Jun 3, 12:21am, Johann 'Myrkraverk' Oskarsson wrote:
}
} specifically, is there a way to compare ^E to 5 and get true?

In the manual under "Arithmetic Evaluation", a few pages down:

 An expression of the form `##X' where X is any character sequence such
 as `a', `^A', or `\M-\C-x' gives the ASCII value of this character and
 an expression of the form `#FOO' gives the ASCII value of the first
 character of the value of the parameter FOO.

zsh% print $((##\C-e))
5
zsh% ((##\C-e == 5)) && print It is 5 || print It is not 5
It is 5
zsh% 

In the manual under "Quoting":

 A string enclosed between "$'" and "'" is processed the same way as the
 string arguments of the print builtin, and the resulting string is
 considered to be entirely quoted.

zsh% print $'\5' | cat -v
^E
zsh% ctrlE=$'\5'
zsh% print $((#ctrlE))
5
zsh% 



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