[Top][All Lists]

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

Re: newlines and $(...) processing

From: Bob Proulx
Subject: Re: newlines and $(...) processing
Date: Sun, 13 May 2007 12:44:27 -0600
User-agent: Mutt/1.5.9i

Andreas Schwab wrote:
> address@hidden (Bob Proulx) writes:
> > But when this is used with a command substitution the newline
> > disappears.
> Command substitution always strips trailing newlines.

Here is the part that I have previously missed:

   man bash

   Command Substitution
       Bash performs the expansion by executing command and replacing
       the command substitution with the standard output of the
       command, with any trailing newlines deleted.  Embedded newlines
       are not deleted, but they may be removed during word splitting.

And this follows POSIX:


  The shell shall expand the command substitution by executing command
  in a subshell environment (see Shell Execution Environment) and
  replacing the command substitution (the text of command plus the
  enclosing "$()" or backquotes) with the standard output of the
  command, removing sequences of one or more <newline>s at the end of
  the substitution.

I somehow missed this when I was researching it previously.


reply via email to

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