Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: fc -l doesn't match %h number?



On Oct 1, 11:54am, Rocky Bernstein wrote:
} 
} Am I doing something wrong? Thought's about what's going on here?

Subshells have their own copy of the history, because they're forked.
I think the history mechanism is becoming confused because it's not
expecting to have anything added to the history in the middle of
command execution.

If you keep going from where you stopped:

hist<3> c
    1  a
    2  b
subshell level: 1
y=4 
hist<4> d
    1  a
subshell level: 0
x=5 
hist<3> 

Note that everything that happened at "level: 1" has vanished, including
the value shown by %h, when we get back to "level: 0".  Add a few more
lines to the script so as to keep going and:

hist<3> e
    1  a
    2  b
subshell level: 0
x=6 
hist<4> f
    1  a
    2  b
    3  e
subshell level: 0
x=7 
hist<5> q

Replace the ( ) with { } and it all works, so it has something to do
with prepping to fork.

Also, nothing is ever written to /tmp/hist even if INC_APPEND_HISTORY
is set, which is probably be a bug in "print -s".



Messages sorted by: Reverse Date, Date, Thread, Author