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

Re: set -o nounset; foo=(); print ${foo:#bar}



On Sep 6,  8:47pm, Roman Neuhauser wrote:
}
}   roman@wrench ~ 0 1078 0 > print ${foo:#bar}
}   zsh: foo: parameter not set
}   roman@wrench ~ 0 1079 1 > 
} 
} the problematic part is ${foo:#bar} triggering nounset.  FMPOV it *is*
} set (but null), so i'd say the observed behavior is a bug.

This seems to be ${name:#word} being confused with ${name:?word} where
the ":" means to treat an empty parameter as unset.  This also affects
the newer ${name:^word} form.

} is it fixable?

I don't immediately see a simple code change that would do so, but I'm
sure it can eventually be fixed.

} or is there at least a good workaround?  (stuffing the
} array with a sentry is not a good workaround.)

You can use ${foo##bar(#e)} with extendedglob, I think, but it may
depend on context.  Without extendedglob I don't see a good way.



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