Hacker News new | past | comments | ask | show | jobs | submit login

Why not Ctrl+Z to get back to the prompt and then cursor up to get the last command? You can `fg` or even `bg` as desired to resume.



Because ctrl-z will stop the current command, and when you run "fg" it resumes that one process. However, the loop you were in has been abandoned, and it will not continue to execute.

For example, try it with this:

    for N in $(seq 10); do echo $N; sleep 1; echo $N; done
You'll see something like this:

    $ for N in $(seq 10); do echo $N; sleep 1; echo $N; done
    1
    1
    2
    ^Z
    [1]+  Stopped                 sleep 1
    $ fg
    sleep 1
    $


Great point.

Also, you may have things talking to external resources that are sensitive to timeouts ... even small ones. You may not be able to cleanly resume execution and cause an entirely new problem.


In zsh, it resumes the entire loop.


So ctrl-c and up arrow wouldn’t work?


After so many months, I had no idea what tools I was running in that command line... And therefore, the effect of any signal seemed far more dangerous to me, than extracting the actual command from my shell's memory.


Ok I get that




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: