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

Re: Odd behavior with various (q) array modifiers and non-printable characters (backspace, newline)



On 2021-08-11 5:22 p.m., Bart Schaefer wrote:
On Wed, Aug 11, 2021 at 4:25 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
TLDR 2: I also learned that (q+) is my new favorite, and my code
should use "command echo" to avoid the above behavior.
I'd like to add the anecdotal remark that there were many situations where I thought I'd solved a problem with (q) or (Q) or (q+) and it turned out that these things only made more trouble in the end. Better solutions were to be found that didn't involve the Q continuum.  Being only semi-literate as I am, sometimes the mystery never did get solved -- I had some issue, (q...) seemed the fix it, then (q...) started breaking things, I remove the (q...) and it seems like there never was a problem to begin with, probably because I made some other change that obviated the original issue.   If Zach's experience is like mine he might end up being weary of the Q himself.

One of my astronomy packages creates this helpful directory and file:


      4096 [2021-01-01--14:03] Sky above 49°30'N 123°30'W at Sun 2020 Dec 20 20 26_files/       22213 [2020-12-20--12:27] Sky above 49°30'N 123°30'W at Sun 2020 Dec 20 20 26.html

... and I always throw any change I make in one of my functions at those files as torture tests because any change is likely to break when it encounters those -- the internal quote or the special characters or the spaces are ultra fragile and only the exactly perfect code handles all of them at the same time.  Q seemed to help at times, but again, it often was a false friend.  I'm still far from clear on how you absolutely, perfectly protect *any* filename or string every time even on Mondays and even if it's a filename that the Devil himself wouldn't make ... but I get closer all the time.  Zach will get the right advice tho and not from me.







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