2

I am encountering no matches found when using map in zsh:

#!/bin/zsh

declare -A map=(["8761"]="Eureka服务" ["11001"]="用户微服务")

Why would this happen, and how can I fix it? This is the error:

~/source/dolphin/dolphin-scripts/bash/tool on  master! ⌚ 20:57:52
$ ./batch-terminal-process.sh
./batch-terminal-process.sh:14: no matches found: [8761]=Eureka服务

2 Answers 2

4

zsh doesn't support the typeset -A array([key]=value ...) syntax from ksh and bash.

Instead of that, you should simply initialize an associative array by alternating keys and values:

% declare -A map=(8761 "Eureka服务" 11001 "用户微服务")
% echo ${map[8761]}
Eureka服务
3

As Uncle Billy said, this syntax was not understood by zsh.

However, support was added in zsh >= 5.5 (see changelog) and your snippet now works.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.