Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dumbsh.fs

15 views
Skip to first unread message

Anton Ertl

unread,
Mar 15, 2009, 1:39:35 PM3/15/09
to
Last sunday (March 8), I wanted to do a shell script that did
something with many of my .ogg files, the names of which contain all
kinds of characters, including some that typical shells and other
tools consider meta-characters (they contain song or album names).
After much frustration, I decided I needed a shell that does not have
meta-characters is in order. So I wrote dumbsh.fs
<http://www.complang.tuwien.ac.at/forth/programs/dumbsh.fs>.

Interestingly, the next day or so, the discussion about the C
interface used execve() as an example, which is an essential system
call in a Unix shell. I use the slightly more refined wrapper
function execvp() (which does path searching, so dumbsh is not totally
dumb).

So you may want to study it as an example of the libcc C interface in
action.

Dumbsh uses only NUL as meta-character (for separating arguments of a
command); since execve/execvp require NUL-terminated strings, this
poses no additional restrictions. The way I used this is
(simplified):

find <dir> -name \*.ogg -printf 'cp\0-p\0%p\000/sansa/MUSIC/\0\0'|gforth dumbsh.fs

The only restriction of the current implementation of dumbsh is that
it cannot pass empty arguments (because it interprets empty arguments
as indicating the end of the command).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html

0 new messages