On Tue, Sep 06, 2022 at 10:11:00PM +0200, Martin Schulte wrote: > Hi! > > > Running with this assumption, now that we know bash's extglob matching > > will not perform suitably for this task, we can look at other approaches. > > Here's another: > > printf -- '%s ' $(gcc --help) | sed 's/ $/\n/' > > Let just do the shell most of the work ;-)
That's not safe. The unquoted substitution will undergo word splitting, which we want, and also globbing, which we do *not* want. You should at least disable globbing first, with set -f. I also don't understand why you used a '%s ' format and then changed spaces to newlines with a second process. You might as well just use a '%s\n' format in the first place, and skip the sed/tr.