I'm writting a shell in Common Lisp that reads command from the user's input and returns the output after executing. When the user types a "meta" command I want to write a placeholder so that the user can either press enter and send that command to the shell, or edit this command as if it were their own input.
This what I have now:
(defun eval-print (command-executor command)
(format t "~a~%" (funcall command-executor command)))
(defun cmd-exec-local (command)
"Execute a command in the local shell"
(trim (uiop:run-program command :output :string)))
(defun shell (command-executor &optional placeholder)
"Simulate a REPL"
(progn
(if placeholder
(format t ">>> ~a" placeholder) ; This is were I try to show a placeholder
(format t ">>> "))
(let ((command (read-line))) ; Check if the user wrote a meta command, else just execute whatever they wrote
(cond ((string= "@exit" command) (format t "Bye!~%")) ; Exit the shell
((string= "@bashrev" command) (shell command-executor *bash-rev*)) ; Bash reverse shell
((string= "@info" command) (shell command-executor "whoami")) ; System info
(t (eval-print command-executor command) (shell command-executor)))))) ; Execute the command
But this is the output I get:
PENTESTING> (shell #'cmd-exec-local)
>>> @info
>>> whoami ; This has been written to the standard output, so even if I press enter, nothing gets executed
>>> whoami ; This was written by the user so when pressing enter, I get the results I need
kali
>>> @exit
Bye!
My guess is I need some kind of buffer that I can write to but I've tried terminal-io and it didn't seem to work.
progninside thedefun.eval-printandtrimfunctions ?eval-print's definition to the OP,trimis imported from the librarystr.*query-io*does not allow such kind of thing you want. And clearly your(format t ">>> ~a" placeholder)doesn't do the trick. I just don't see how it all relates to SLIME. You'd better remove all references to Slime in your question (and remove the slime tag)