Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: array not working



On Nov 26, 12:53pm, zzapper wrote:
} Subject: Re: array not working
}
} zzapper <david@xxxxxxxxxx> wrote in
} news:Xns98877CBF8A380zzappergmailcom@xxxxxxxxxxx: 
} 
} > Hi a previously working zsh script

Are you running this stand-alone or is it loaded as a shell function?

Did you update any any other part of Cygwin recently?

} > someurl=(database login password filename)
} > 
} > "$mysqldump" $param -h $server -u${someurl[1]} -p$someurl[2] -B
} > ${someurl [0]} > ${someurl[3]}.sql

I'm going to assume the space before [0] is a line wrapping artifact.

} > What is happening is that ${someurl[1]} $someurl[2] ${someurl[0]}
} > are all evaulating to the same value (first element in array)

Quite frankly I'm not sure how this ever worked.  With the ksh_arrays
option NOT set, ${someurl[1]} and ${someurl[0]} should always have been
the same value, and WITH ksh_arrays set, $someurl[2] is the same as
${someurl}[2] which would be interpreted as a file pattern (and either
error with "no match" or result in one of "database[2]" or nothing,
depending on the nomatch and nullglob options).

There is no case I know of where [[ ${someurl[1]} == $someurl[2] ]]
would be true, given the shown starting state of the array.

} > what daft thing am i doing?

I can't think of any combination of setopts that would produce your
desired effect with that assortment of subscripting and braces.

} Started new shell and problem went away, but arrays now seem to be
} indexed from 1 rather than zero?? 
} 
} Did this change recently?

As Nikolai said, no, it did not.  Aside from the impossible scripting
above, could it be that someone has changed something in a startup file?
Perhaps in the Cygwin equivalent of /etc/zshenv or similar?



Messages sorted by: Reverse Date, Date, Thread, Author