Update Looking through this link, I updated the array subscript to start with 1 instead of 0 and seems like the array variable is read properly.
#!/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.
But I start seeing errors else where for my previously declared shell functions not being recognized.
command not found: git
So I think the generalized question is:
How do I port my perfectly running shell scripts written to run in bash shell to zsh shell?
I recently upgraded my Mac to macOs Catalina 10.15.2
One of my shell scripts that looks like this:
#!/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.
This used to work fine when my default shell was a bash shell. All I am doing here is adding a few folders to an array variable that I am going to use in the shell script. Post the upgrade and making my default shell as zsh, I see the following error when I start the script (through an alias in my .zsrc file)
[ayusman@~10:39AM]$updateExpediaGitRepos
/Users/ayusman/scripts/updateGitRepos.sh:250: ROOT: assignment to invalid subscript range
[ayusman@~10:39AM]$
I verified that when I change my shell back to bash (by doing chsh like below), the same script runs as expected.
chsh -s /bin/bash
So essentially the question is can I not use my existing bash scripts as it is and run from a zsh shell?
Thanks, Ayusman
zsh
version?