I’ve got function
calc() {echo "${1}"|bc -l;}
it works for 2+2 but when I want something alike 10^4
calc 10^4
zsh: no matches found: 10^4
yes I’m getting the same with bc -l
>>echo 10^4|bc -l
zsh: no matches found: 10^4
but to solve it I’ve added quotes
>>echo "10^4"|bc -l
10000
how to implement it in function? if I do "\"${1}\"" it will just echo the string…
^is a special character whenEXTENDED_GLOBoption is enabled inzsh. It’s expanded before your function is called, so there’s no workaround possible inside the function.You can disable
EXTENDED_GLOBaltogether:or provide an alias for interactive use, which would expand into
noglob calc, preventing filename expansion: