bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parameter expansion with extended pattern make system hang


From: Greg Wooledge
Subject: Re: Parameter expansion with extended pattern make system hang
Date: Tue, 6 Sep 2022 16:27:53 -0400

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]