On 6/8/19 3:41 PM, _...@crans.org wrote:

> Bash Version: 5.0
> Patch Level: 7
> Release Status: release
> 
> Description:
>       When `eval` runs "set -o history", subsequent lines in the
>       eval-ed string are recorded in the history.

Yes. History doesn't require an interactive shell to work; you can save
commands in the history list and use the history commands to operate on
them in any shell that runs `set -o history'.

> 
>       This breaks the following coding pattern:
>               saved_options="$(set +o)" # save shell options
>               ... # do some things with custom shell options
>               eval "$saved_options" # restore shell options
>       Indeed, if history is enabled (which is very likely), then the
>       output of "set +o" will include the line "set -o history",
>       followed by lines for enabling or disabling other options, and
>       these following lines pollute the user’s history.
> 
>       What makes me think it is an actual bug is that when the
>       "history" option was already enabled, "set -o history" should
>       have no effect; yet lines before are not recorded, and lines
>       after are recorded.

Bash temporarily stops recording commands in the history when you use
`eval', but if you turn history back on explicitly using `set -o history',
it will honor that.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to