bug-bash
[Top][All Lists]
Advanced

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

Re: Spaces in args, escapes, and command substitution


From: Eric Blake
Subject: Re: Spaces in args, escapes, and command substitution
Date: Sun, 29 Oct 2006 07:20:13 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to bash@zacglen.com on 10/29/2006 3:39 AM:
> Why is it that word splitting never makes a distinction between
> newlines and space?

Because POSIX, and tradition, say so.

>  Because the output of grep -l, and ls, etc are
> clearly newline delimited.

That is a flawed argument.  Filenames can contain newlines.  The only SAFE
way to pass arbitrary filenames is null-delimited, if you are truly
worried about metacharacters in the name.  True, spaces are more common
than newlines, but if you are going for safety, then go all the way.

> It is bash (and others) which quite deliberately
> reduce available information by converting all newlines and whitespace
> into a single space.

Only when told to do so by IFS on underquoted variable expansions and
process substitutions.

> 
> Something simple like "vi $(^grep -l xx *)" would do.
> The ^ might work because it denotes line-orientated regex (and nobody
> uses it for pipes any more).

Actually, that is well-defined by POSIX to invoke the command '^grep'.  If
you are going to propose a new operator, you had better choose one that
POSIX leaves unspecified.  But you are correct that no one uses ^ for
pipes any more - POSIX does not allow ^ to mean pipes.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFRLic84KuGfSFAYARAkpJAKDPaGqatGxoa/+MNa1KkxXrDT5b/gCgj8M7
dITpRD31yQbvBtywLEF9nK4=
=gJ9Z
-----END PGP SIGNATURE-----




reply via email to

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