zsh: no matches found

Square brackets are interpreted as a pattern on the command line. Two improvements over the default behavior.

Leigh Johnson
Nov 2, 2020

Originally published via bitsy.ai

I’ve been using zsh and ohmyz.sh for years, but I still occasionally forget this shell interprets square brackets as a pattern on the command line.

Here’s an example:

$ which $SHELL
/usr/bin/zsh
$ pip install -e .[develop,plugins]
zsh: no matches found: [develop,plugins]

Instead of installing the develop and plugins variant of this Python package, zsh attempted to match this pattern. To account for this, I need to escape the square brackets:

$ pip install -e .\[develop,plugins\] 
Obtaining file:///home/leigh/projects/OctoPrint

If I need a more permanent fix, I can use an alias to set -o noglob (disable shell globbing) for a command is run by adding this to my .zshrc file:

alias pip='noglob pip'

Bitsy.ai helps you teach yourself Computer Vision, Natural Language Processing, and Deep Learning with hands-on projects for Raspberry Pi, Arduino, and more.

--

--

Leigh Johnson
Leigh Johnson

Written by Leigh Johnson

Building automation/monitoring for 3D printers: https://www.printnanny.ai/ | Applied ML and Edge ML: https://bitsy.ai/ | Google Developer Expert.

No responses yet