On 7/25/21 1:09 PM, andrej--- via Bug reports for the GNU Bourne Again
SHell wrote:
Bash Version: 5.1
Patch Level: 8
Release Status: release
Description:
An extglob like +(!(x))y causes Bash to freeze with a 100% CPU
utilization.
At the first glance the freeze doesn't seem to depend on the
(non-)existence of matching paths.
Repeat-By:
echo +(!(x))y # This freezes!
I can't reproduce this. This is a terribly inefficient pattern, and the
behavior is proportional to the number of files and length of filenames.
In the bash build directory, for instance, it fails right away, as it
should: there aren't any files ending in `y'. In /tmp, with fewer files
but longer filenames, it takes *much* longer.
I agree that interactive shells could be more responsive to SIGINT. It's
a question of checking for the flag the signal handler sets while
executing the pattern matcher itself, rather than solely in the upper
layers. This pattern spends a lot of time in a single call to strmatch(),
which matches a single filename against a pattern, and the current code
checks for SIGINT around calls to strmatch().
--
``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/