更新 查看此链接,我更新了数组下标以 1 而不是 0 开头,并且看起来数组变量已正确读取。
#!/bin/bash
#Root folders for Git update.
ROOT[1]="/Users/ayusman/dev/repos1"
ROOT[2]="/Users/ayusman/dev/repos2"
#do some things with the ROOT variable.
Run Code Online (Sandbox Code Playgroud)
但我开始在其他地方看到错误,因为我之前声明的 shell 函数未被识别。
未找到命令:git
所以我认为普遍的问题是:
我最近将 Mac 升级到 macOS Catalina 10.15.2
我的 shell 脚本之一如下所示:
#!/bin/bash
#Root folders for Git update.
ROOT[0]="/Users/ayusman/dev/repos1"
ROOT[1]="/Users/ayusman/dev/repos2"
#do some things with the ROOT variable.
Run Code Online (Sandbox Code Playgroud)
当我的默认 shell 是 bash shell 时,这曾经工作得很好。我在这里所做的就是将一些文件夹添加到我将在 shell 脚本中使用的数组变量中。发布升级并将我的默认 shell 设置为 zsh,启动脚本时出现以下错误(通过 .zsrc 文件中的别名)
[ayusman@~10:39AM]$updateExpediaGitRepos
/Users/ayusman/scripts/updateGitRepos.sh:250: ROOT: assignment to invalid subscript …Run Code Online (Sandbox Code Playgroud)