M
M
Maxim Zubenko2022-02-03 11:17:04
zsh
Maxim Zubenko, 2022-02-03 11:17:04

How to make the zsh terminal understand the asterisk ( * ) when working with pip (python manager) in the same way as bash?

Yesterday I tried on MacOs, and today on Linux Manjaro. The result was equally unsatisfactory.

The bottom line is that (for example) to install the latest version of django of the third branch, I use the following command:
pip install django==3.*
and bash understands perfectly well that you need to find which one is the latest (and at the time of this writing this is version 3.2.12) and install.
But zsh writes the following:
zsh: no matches found: django==3.*
well, I’ll never believe that I’m so unique and no one has ever encountered anything like this before. And if so, then there must be a solution. I searched through Google / Yandex and did not find it. Maybe they can advise here.

61fb8f34a8354962226170.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2022-02-03
@JawsIk

In command
pip install django==3.*
Neither bash nor zsh looks for the latest version of django for you. This is what pip does by itself
Using wildcard characters can actually lead to a non-obvious situation where

$ echo Hello* World
Hello* World
$ touch Hello1
$ echo Hello* World
Hello1 World

That is, bash, if it finds something by the mask, substitutes it, if it doesn’t find it, it doesn’t substitute it and silently sends the characters as is to the wildcard command.
This leads to non-obvious errors, about which, as it were, there are no error messages, but an error can happen.
In zsh, this moment was taken into account and made so that if nothing is found on the wildcard, then zsh is not silent, but gives an error. And therefore, an unescaped wildcard will not go into the command.
It was done on purpose so that the user would not be stupid, but would escape wildcard characters, and would not hesitate to use quotes and backslashes.
Therefore, if these are not file wildcard characters, but an argument for the pip command, escape it, quote it, and change your "it's inconvenient for me" habit into "it's right".
noglob pip install django==3.*
alias pip="noglob pip"
PS You can disable this globally via "setopt NOMATCH" or something like "setopt nonomatch"
PPS yes, these are elementary things that you ask not to learn, but this is exactly the case when you are wrong, because you confuse the wildcard shell and the options of the command that is inside also supports characters like ? and *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question