How to stop zsh from expanding * (asterisks) on the command line?

I recently switched to zsh. When I used it bash, I used it echo 2*3 |bcas a powerful and convenient calculator, but in the zshfirst part of the command it led to an error message:

$ echo 2*3
zsh: no matches found: 2*3

I know that I can avoid the extension by adding a quote to the line 2*3, but is it possible to bring this function from bash(without expanding the asterisk in the command argument)?

UPDATE:

In the sense, when I found that it bc <<< 2*3does not cause the extension, it is strange :-(

+4
source share
1 answer

You can do:

noglob echo 2*3 | bc

And then create an alias around this:

calc()
{
   echo $* | bc
}
alias calc='noglob calc'
+3
source

Source: https://habr.com/ru/post/1524854/


All Articles