In a previous article, I asked how to call system services from SP-Forth. Of course, it is easy to call libc and other dynamic libraries from SP-Forth.
~/frt/fpForth$ rlwrap ./spf.nux SP-FORTH - ANS FORTH 94 for Linux Open source project at http://spf.sf.net Russian FIG at http://www.forth.org.ru ; Started by A.Cherezov Version 4.20 Build 001 at 24.Feb.2013
(( S" ls *.f" )) system DROP ansi-block.f fsm.f martinBrad.f sbnf.f xconsole.f bernd.f gram.f
mbrad.f sexp.f xeca.f brad.f grammar.f mulmat.f strings.f zeca.f Ok
However, if I call cd (change directory), SP-Forth seems to ignore my command.
(( S" cd $HOME" )) system DROP Ok (( S" pwd" )) system DROP /home/rosa/frt/fpForth Ok
As you can see, the command S" cd $HOME" was ignored. I believe that system creates a new shell, changes the directory in the new shell, and reverts to the old shell when control is returned to SP-Forth. My question is: How to inhibit this behavior? Since I want to create a shell language piggybacked on SP-Forth, I need a persistent cd command.