shell - How to get quoted arguments in the correct way? -
i've got function
calc() {echo "${1}"|bc -l;} it works 2+2 when want alike 10^4
calc 10^4 zsh: no matches found: 10^4 yes i'm getting same bc -l
>>echo 10^4|bc -l zsh: no matches found: 10^4 but solve i've added quotes
>>echo "10^4"|bc -l 10000 how implement in function? if "\"${1}\"" echo string...
^ special character when extended_glob alternative enabled in zsh. it's expanded before function called, there's no workaround possible inside function.
you can disable extended_glob altogether:
setopt no_extended_glob or provide alias interactive use, expand noglob calc, preventing filename expansion:
alias calc='noglob calc' shell zsh
No comments:
Post a Comment