Ok thats a bold claim. I'm not going to do the research to prove it. But to me this is awsome.
I'm working on http client and server support for xmlsh so that I can use xmlsh to prototype a content server. Not quite complete yet, but for an example, this code implements a full HTTP server serving content from the current directory tree. I tested it out by cd'ing to the JDK docs/api directory and launching IE with "http://localhost/index.html" - works !
-- xmlsh code
get () { cat ${PWD}$1 ; }
httpserver -port 80 -get get start
--
Thats it !
Every GET request gets executed by the local "get" function which cats out the file.
Speaking of "cat" though, I've decided that I need to implement basic unix commands natively in xmlsh. Originally I didnt want to do this because it was "reinventing the wheel", but the above example is a great case for it. In the above, the get() method acutally has to spawn 3 threads and a subprocess just to cat the file.
There is no native syntax to stream from input to output without running a command.
If these were all xml files then I could use "xcat" which would be very efficient, or even "xread a < file ; xecho $a;" but for text files there is no builtin "cat" command so its subproces/thread time. Yuck !
Similar for some of the basic unix commands like touch,mv,cp,cat,rm,mkdir,ls.
All of these require a unix subsystem currently (like a real unix OS or cygwin).
It would be very nice if these basics were 'built in'. I'm thinking of truely building them in as internal commands (very simplified option set) or as an "extension module". Comments appreciated.
The advantage would be not only performance on the basic commands, but also usability. A pure xmlsh script could depend on these basic commands existing.
For example the test cases check the environment for these commands already, it would be nice if they could be relied on.
This is now checked in to xmlsh 0.0.2.2 in the "experimental" command set
ReplyDeletePosix commands are now in xmlsh 0.0.2.2 under the "posix" command set
ReplyDeleteSimple just got simplier. With the latest checkin (upcoming in 0.0.2.3) this is now a "1 liner"
ReplyDeletehttpserver -port 80 -get 'cat $(xfile . $1)' start