bashlex icon indicating copy to clipboard operation
bashlex copied to clipboard

fix #99: implement commented string_quote_removal

Open WillForan opened this issue 1 year ago • 4 comments

WillForan avatar Dec 29 '24 19:12 WillForan

Thanks, can you make this work in 3.7 as well?

idank avatar Dec 30 '24 18:12 idank

I worried the walrus operator was suspicious, albeit more concise. hopefully removing it does the trick for py3.7

WillForan avatar Dec 30 '24 18:12 WillForan

There seems to be more to this function than just single quotes: https://github.com/bminor/bash/blob/master/subst.c#L11892

Like double quotes, escape characters. Can you maybe leave a todo if you're not going to add that part?

idank avatar Dec 31 '24 11:12 idank

sorry for the long delay! The initial start/end strip now handles double quotes. And within token quotes and escaped-quotes are managed.

I'm not sure I've gotten the edge cases correct. And I'm assuming unbalanced non-escaped quotes would have had a parsing error before getting here. currently string_quote_removal removes all non-escaped quotes without checking if they're paired.

Surprisingly (to me) these are all valid bash HEREDOCs

cat << "HERE\"DOC"
example: quote in quote
HERE"DOC

cat << HERE\"DOC
example: one double quote
HERE"DOC

cat << HERE"x"DOC
example: string 
HERExDOC


WillForan avatar Jan 19 '25 02:01 WillForan