Trying to figure out when spaces are and aren't allowed in ${blah} led to asking why echo ${!a* } is an error but ${!a@ } isn't (when there are no variables starting with a), and I eventually worked out that:
$ X=PWD $ echo ${!X@Q} '/home/landley/toybox/clean' Is going on? Which is just weird, both because: $ echo ${PATH@ } bash: ${PATH@ }: bad substitution And because: $ ABC=defghi; echo ${#ABC@Q} bash: ${#ABC@Q}: bad substitution $ echo ${PWD:1:3@Q} bash: PWD: 3@Q: value too great for base (error token is "3@Q") $ echo ${PWD:1@Q} bash: PWD: 1@Q: value too great for base (error token is "1@Q") Hmmm... $ echo ${!potato@walrus} $ echo ${!P@walrus} $ echo ${!P@} PATH PIPESTATUS PPID PS1 PS2 PS4 PWD $ X=PATH $ echo ${!X@ } bash: ${!X@ }: bad substitution $ ABC=123 $ echo ${!A@walrus} $ echo ${!ABC@} ABC $ echo ${!ABC@walrus} $ echo ${!A@ } Ok, when X exists and points to another variable, then !X becomes the contents of that other variable and THEN the @ cares about trailing garbage. But * is a different codepath from @...? And when the ${!var} doesn't have contents pointing to another existing variable, it falls back to a codepath that tries the prefix stuff (and/or the array stuff, in some order?) and that codepath tries to parse trailing @Q and friends, but DOESN'T error out if it can't recognize the trailing stuff after the @? I'm pretty sure the array mangling logic ties in here somehow, but there's some missing error checking somewhere... Anyway, I'm confused again. Did I miss something in the man page? $ ABC=PATH $ echo ${!ABC:1:2@Q} bash: !ABC: 2@Q: value too great for base (error token is "2@Q") $ echo ${!ABC:1:2 @Q} bash: !ABC: 2 @Q: syntax error: invalid arithmetic operator (error token is "@Q") Which to be honest is more like what I expected, it sees the : and goes "ah, consume the remainder in THIS mode"... $ echo ${abc#23@Q} 123 But if ANYTHING was going to recognize @Q at the end of another operation I'd expect it to be : which already has to recognize further punctuation, but no: $ ABC=123; echo ${ABC:@Q} bash: ABC: @Q: syntax error: operand expected (error token is "@Q") Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net