[arch-projects] [mkinitcpio][PATCH 09/26] functions: specify the delimiter to xargs
Dan McGee
dpmcgee at gmail.com
Tue Sep 27 00:02:12 EDT 2011
On Mon, Sep 26, 2011 at 10:48 PM, Dave Reisner <d at falconindy.com> wrote:
> On Mon, Sep 26, 2011 at 10:46:57PM -0500, Dan McGee wrote:
>> On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner <d at falconindy.com> wrote:
>> > Without specifying this, xargs will split arguments on whitespace as
>> > well as newlines, and will interpret quoting and backslashes. When the
>> > delimiter is specified, every character is taken literally and only the
>> > given delimiter in honored.
>> >
>> > This sidesteps issues with broken modalias files as evidenced by a
>> > MacBookAir3,1 or the bbs thread below:
>> >
>> > https://bbs.archlinux.org/viewtopic.php?pid=971853
>> >
>> > Also fixes FS#25450.
>> >
>> > Signed-off-by: Dave Reisner <dreisner at archlinux.org>
>> > ---
>> > functions | 2 +-
>> > 1 files changed, 1 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/functions b/functions
>> > index 8ce24ea..7f9202f 100644
>> > --- a/functions
>> > +++ b/functions
>> > @@ -117,7 +117,7 @@ auto_modules() {
>> >
>> > IFS=$'\n' read -rd '' -a mods < \
>> > <(find /sys/devices -name modalias -exec sort -u {} + |
>> > - xargs modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" |
>> > + xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" |
>> Dollar sign what? /me doesn't follow this at all, a comment would be great.
>
> consult your manual, sir!
>
> Words of the form $'string' are treated specially. The word expands
> to string, with backslash-escaped characters replaced as specified by
> the ANSI C standard. Backslash escape sequences, if present, are
> decoded.
>
> In other words, its expanded in place. Yeah, this seems elementary to
> me, but I suppose its comment worthy.
Well when you say "consult your man page", I thought to myself, "Damn,
did I really miss that? Let's read again."
--delimiter=delim
-d delim
Input items are terminated by the specified character. Quotes
and backslash are not special; every character in the input is
taken literally. Disables the end-of-file string, which is
treated like any other argument. This can be used when the in‐
put consists of simply newline-separated items, although it is
almost always better to design your program to use --null where
this is possible. The specified delimiter may be a single char‐
acter, a C-style character escape such as \n, or an octal or
hexadecimal escape code. Octal and hexadecimal escape codes are
understood as for the printf command. Multibyte characters are
not supported.
Nope! Nothing there.
Then I realized "Oh! He is talking about some bash feature and THAT is
the manpage I'm supposed to be reading."
It isn't elementary to those of us that don't use shell as much as
you, and RTFM on a 5439 line gargantuan manpage is not my idea of fun,
not to mention the 118 lines of hits for the literal '$' character
(because I would have no idea in hell how else to find it).
-Dan
More information about the arch-projects
mailing list