in reply to Navigating history of STDIN-multiliners after 'perl RET'

Bash, for reasons unknown to me, disables the previous-command type functionality when reading from standard input.

You can get the behavior you're looking for with rlwrap. On my debian-based box, it was simple to install with "apt-get install rlwrap"

Then, just run "rlwrap perl" instead of "perl", and it should do what you want.

  • Comment on Re: Navigating history of STDIN-multiliners after 'perl RET'

Replies are listed 'Best First'.
Re^2: Navigating history of STDIN-multiliners after 'perl RET'
by LanX (Saint) on Dec 25, 2016 at 21:41 UTC
    Hi kschwab

    > Then, just run "rlwrap perl" instead of "perl", and it should do what you want.

    Thanks, I knew rlwrap and it's already installed. :)

    I erroneously thought that on Win I'm able to navigate the whole chunk of code from the last call to perl instead of just reconstruction line after line.

    But it turns out I was wrong.

    Probably there is an option for rlwrap to treat the whole chunk as one line. Have to look into it.

    For me there is a gap to be filled between improvised one-liners and persistent scripts.

    I also tried putting all into a bash heredoc but either my bash foo is too weak or interactive input is treating heredocs differently

    $ perl -e <<___ if(1) { print 44; } ___ No code specified for -e.

    EDIT:

    But while composing this post I noticed that this syntax does what I want:

    $ perl <<___ if(1) { print 44; } ___ 44 # arrow up $ perl <<___ if(1) { print 44; } ___

    Of course on bash only :(

    update

    unfortunately the "solution" I found is messing up STDIN pipes

    lanx@lanx-1005HA:/tmp$ ls |perl -n <<___ print if /a/ ___ lanx@lanx-1005HA:/tmp$ ls |perl -ne ' print if /a/ ' atop.d at-spi2 mkinitramfs_JrDw4Q mkinitramfs-OL_Ahxk1r

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!