When I find myself in times of arithmetic trouble¹, I like to simply calculate on my shell
> echo $(( 3**4 - 2/7*5 ))
which of course works beautifully. However, I find that it's too much typing, so I defined
function §()
echo $(( $@ ))
which allows me to
> § '3**4 - 2/7*5'
but not
> § 3**4 - 2/7*5
Because zsh tells me it could find no matches (or worse, expands filenames if there are some matches).
How can I tell the zsh shell that I want it to not interpret things entered as arguments to a function as globs?
I don't want to do something like
> enter_non_glob_mode
> 3**4 - 2/7*5
> back_to_normal_mode
because instead of that, I could as well start dc, python…
¹Mother Euler speaks to me, wispering words of wisdom, power of e... SCNR.
Use the noglob modifier.
% noglob § 3**4 - 2/7*5
81
To avoid having to type noglob each time, use an alias to insert the modifier. (You can't put noglob inside the function, as pathname expansion will have already taken place before the body is evaluated.)
% alias §='noglob §'
% § 3**4 - 2/7*5
81
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With