bug-bash
[Top][All Lists]
Advanced

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

Re: Enabling History Expansion with `set -H'.


From: Clint Hepner
Subject: Re: Enabling History Expansion with `set -H'.
Date: Sun, 21 Jan 2018 09:31:08 -0500

> On 2018 Jan 21 , at 7:13 a, Ralph Corderoy <address@hidden> wrote:
> 
> Hi,
> 
> Please keep me CC'd.
> 
> bash package 4.4.012-2 on Arch Linux,
> `version 4.4.12(1)-release (x86_64-unknown-linux-gnu)'.
> 
> I'm trying to enable history expansion in a non-interactive bash with
> `set -H'.
> 
>    $ printf '%s\n' ': foo' 'echo !!' 'set -H' ': bar' 'echo !!' |
>> bash 
>    !!
>    !!
>    $
> 
> I'd expect the second `!!' to be `: bar'.
> What am I misunderstanding?

You enabled history *expansion*, but not the history mechanism itself, so there 
is nothing for !! to expand to. You need `set -o history` as well.

    $ printf '%s\n' ': foo' 'echo !!' 'set -H -o history' ': bar' 'echo !!' | 
bash
    !!
    echo : bar
    : bar

The second line, 'echo : bar', is the result of the expansion itself, prior to 
the resulting command actually being executed.
    


reply via email to

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