@@ -579,6 +579,28 @@ fn %pathsearch name { access -n $name -1e -xf $path }
579579
580580if { ~ <= $ & primitives execfailure } { fn - % exec - failure = $ & execfailure }
581581
582+ # The % write - history hook is used in interactive contexts to write
583+ # command input to the history file ( and / or readline 's in - memory
584+ # history log ) . By default , $ & writehistory ( which is available if
585+ # readline is compiled in ) will write to readline 's history log if
586+ # $max - history - length allows , and will write to the file designated
587+ # by $history if that variable is set and the file it points to
588+ # exists and is writeable .
589+
590+ if { ~ <= $ & primitives writehistory } {
591+ fn - % write - history = $ & writehistory
592+ } {
593+ fn % write - history input {
594+ if { ! ~ $history ( ) } {
595+ if { access - w $history } {
596+ echo $input >> $history
597+ } {
598+ history = ( )
599+ }
600+ }
601+ }
602+ }
603+
582604
583605#
584606# Read - eval - print loops
@@ -625,24 +647,9 @@ if {~ <=$&primitives execfailure} {fn-%exec-failure = $&execfailure}
625647# The parsed code is executed only if it is non - empty , because otherwise
626648# result gets set to zero when it should not be .
627649
628- fn - % is - interactive = $ & isinteractive
629650fn - % parse = $ & parse
630651fn - % batch - loop = $ & batchloop
631-
632-
633- if { ~ <= $ & primitives writehistory } {
634- fn - % write - history = $ & writehistory
635- } {
636- fn % write - history input {
637- if { ! ~ $history ( ) } {
638- if { access - w $history } {
639- echo $input >> $history
640- } {
641- history = ( )
642- }
643- }
644- }
645- }
652+ fn - % is - interactive = $ & isinteractive
646653
647654fn % interactive - loop {
648655 let ( result = <= true ) {
0 commit comments