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

Re: saved from prince of eval



On 11/09/2015 10:41 AM, Bart Schaefer wrote:
    IN[PAGE]=${${(P)IN[list]}[IN[topE],IN[bottomE]]}

Thanks.

I've realized that my friend '(e)' was with the Enemy all along. I have a function that prints out a half sane modification of 'set', and sure enough:
}      foo="\$${IN[list]}[${IN[topE]}, ${IN[bottomE]}]"
}      IN[PAGE]="${(e)foo}"
Ended up 'evaling' the content and doubling the size of my environment every time it was run. It's seems strange tho, how can a parameter be set twice (or 16 times) to exactly the same value? But your line above seems, finally, to do what it's asked to do without evaling anything.

Speaking of which, we have 'env' which only gives us the--don't know the proper term--lowest level system stuff. And we have 'set' which gives us everything including the kitchen sink. So I have this:

   #1) strip out the color.
   #2) cut lines down to 80 chars (some are a thousand).
   #3) select only things that are probably variables.
   eenv ()
   {
        set |
        sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" |
        sed 's|^\(.\{1,80\}\).*|\1|' |
        grep --binary-files=text '='
   }


... which is an effort to display just the current parameters. However the output refuses to open in any of my editors if piped to a file, they all think it's binary. Looking at it in hex, I see that it's a soup of backslashes and single quotes. Why is that? Is there a civilized way of listing all current parameters that's just plain text, no backslashes? Not knowing the hierarchy, perhaps even avoiding those deep things like 'color=' which isn't something one wants to look at very often--those deep internal things that have nothing to do with the user. It would be a useful thing.




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