help-bash
[Top][All Lists]
Advanced

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

Re: i vote for $( .. <file ) be available also as non first command in s


From: Alex fxmbsw7 Ratchev
Subject: Re: i vote for $( .. <file ) be available also as non first command in subshells ( and maybe process subst ) ?
Date: Fri, 12 Mar 2021 16:48:48 +0100

i just say it should be globally available, as cat replacement, not just as
first command to subshells

but oh well =)

On Fri, Mar 12, 2021, 16:21 Chet Ramey <chet.ramey@case.edu> wrote:

> On 3/12/21 8:10 AM, Greg Wooledge wrote:
>
> > OK, first things first: $(<file) is special syntax.  It is defined to
> > be equivalent to $(cat file), except that it doesn't need to exec cat(1),
> > so it is marginally more efficient.
>
> Sort of, but not in the way you think. It's not an operator, nor is it
> determined lexically.  In other words, it is not this:
>
>  > It's
>  > a new piece of syntax that consists of three characters, but you're
>  > allowed to put whitespace between the second and third character.
>
> but rather a command substitution that contains a single simple command
> that consists solely of a single input redirection. This requires parsing
> it, which currently happens in the subshell since that's where command
> substitutions are parsed.
>
> It looks more like this pseudo-regexp:
>
> $\([[:blank:]]*<([!<&->]|[[:blank:]]*)[![:blank:])]*.*\)
>
> but that doesn't exactly capture it since it doesn't take into account the
> fact that `file' can be quoted, and it's tricky to capture the restriction
> that the character immediately following the `<' can be anything but a
> character that defines a different redirection operator. I need better
> regexp-fu to write the correct one.
>
> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>
>


reply via email to

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