[Top][All Lists]

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

Re: Multi-line, double quoted string triggers history expansion on subse

From: Chet Ramey
Subject: Re: Multi-line, double quoted string triggers history expansion on subsequent single-quoted commands it gets piped to
Date: Wed, 15 Jun 2016 09:36:16 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.1.1

On 6/14/16 8:52 AM, Néstor Tejero wrote:

> When printing a multi-line string and piping to another command that uses
> single-quotes, Bash tries to perform history expansion:
> echo "9
>> 10
>> 9
>> 11" | awk '!seen[$0]++'
> bash: !seen[$0]++': event not found

History expansion is explicitly line-oriented.  It doesn't know about shell
state, especially shell quoting state, that spans lines. It does know about
vaguely shell-like quoting that's common across a large set of Unix
utilities -- since the history and readline libraries are used outside the
shell --  and that a double quote introduces a quoted string in which
single quotes are not significant and don't inhibit history expansion.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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