would cause the shell to freeze in an infinite loop.
Per the man pages:
[...] `a' and `g' can be used together to apply a
modifier globally. With the `s' modifier, only the pat‐
terns contained in the original word are substituted, not
patterns that contain any substitution result.
So, keep track of where the last substitution was made, and continue on from
there.
Running this:
would cause the shell to freeze in an infinite loop.
Per the man pages:
So, keep track of where the last substitution was made, and continue on from there.