On Fri, Dec 29, 2017 at 12:43 PM, Bart Schaefer wrote: > On Fri, Dec 29, 2017 at 7:29 AM, Jim wrote: > > Hello, > > > > The intent is, using only "native zsh" tools, return the 'shell' > > as set in /etc/passwd for my own $USER without using any external > > utilities, gnu or otherwise. As in UNIX/Linux, zsh also has more then > > one way of doing the same thing. So as a training exercise I decided > > to use as many variants as I could to do the same thing. In the process > > I found that what I though would work, did not return the intended > > result. > > I haven't gone through your cases in any detail, but there are almost > certainly three things causing your problems: > (1) Nested expansions plus quoting cause an array in the inner > expansion to be joined into a string in most cases, unless you use > special syntax to preserve the array > (2) Single-element arrays behave like scalars (strings) in several cases > (3) Subscript syntax applies to scalars, to extract substrings > I can see this from my testing. > > Those last two put together can cause a lot of head-scratching. > > I believe I do my fair share, and not only on this. > > Figuring out at what level of a nested expansion you need to add (A) > or (@) is the other part of the equation. Sometimes you need to add > an extra level of nesting just to force (A) to be applied to the > correct value. > > AFAICT ..."${(f)"$(