Add `-n` and `-e` options to `print`
vinc opened this issue · 2 comments
We could add the -n
option (from Unix v7) to avoid printing a trailing newline, and the -e
option (from Unix v8) to interpret escape characters like Bash. The latter could also be done automatically by the command (and disabled with -E
) like Zsh or by the shell.
https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins
https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html
https://www.cs.dartmouth.edu/~doug/reader.pdf
https://www.everything2.com/title/The+UNIX+and+the+Echo
This should simplify scripting of the socket
command:
print -e -n "GET / HTTP/1.1\r\nHost: moros.cc\r\n\r\n" => /tmp/http.cmd
socket moros.cc 80 <= /tmp/http.cmd
Or when pipes will be implemented:
print -e -n "GET / HTTP/1.1\r\nHost: moros.cc\r\n\r\n" -> socket moros.cc 80
Both options will require alloc in userspace to be implemented in a simple way.
The arguments of the command that are not options will be collected in a vector to be printed at the end with a space between each argument (with join
), after every escaped characters has been interpreted (with replace
) if the option -e
was used.
This can currently be done this way:
print "GET / HTTP/1.1" => /tmp/http.cmd
print "Host: moros.cc" =>> /tmp/http.cmd
print =>> /tmp/http.cmd
lisp lf-to-crlf.lsp /tmp/http.cmd
socket moros.cc 80 <= /tmp/http.cmd
Closing for now.