On 9/4/22 10:48 PM, Hyunho Cho wrote:

Bash Version: 5.1
Patch Level: 16
Release Status: release

##############################################################


#### "gcc --help" is already a short string, but the system hangs.

A short string? It's 90K on my system.

( without using extended pattern, there is no such problem )

bash$ help=$( gcc --help )

bash$ echo "${help//+([$' \t\n'])/ }"

So what you're doing is taking a 90K string, and for each character in the
string, trying to match it against successively shorter substrings,
starting at the end to preserve the required `leftmost longest' match
semantics. It's worse because you can't calculate the pattern length here,
so you can't bound the search at all. Nor are you building a regular
expression and trying to execute it against the strings; this is just a
simple pattern matcher.

It's hard to think of a less efficient way of doing whatever it is you're
trying to do.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to