Questions about windows support

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Feb 21 18:05:28 PST 2012


On Wed, Feb 22, 2012 at 01:33:56AM +0100, Adam D. Ruppe wrote:
> Thinking about globbing, I think rm * is a mistake
> anyway...
> 
> The way I'd do programs is something like this:
> 
> echo input > program_name options....
> 
> So, you wouldn't rm *. You'd ls | rm.
> 
> You'd implement rm like this:
> void main() {
>      foreach(file; stdin.byLine)
>          std.file.remove(file);
> }

Hmm. Let's implement shell utilities in D! (Pointless, yeah, but a fun
exercise to see how much cleaner D code can be -- if you've ever looked
at that creeping horror that is the source code for 'less'.)


[...]
> This way, options and things to operate on
> are nicely separated, and you can process
> the input with more filters easily.
> 
> glob * | grep 'poo' | rm

Interesting idea. This calls for ... a shell written in D. :-)


[...]
> Windows Powershell actually kinda works this way,
> from what I know of it. You can do
> 
> ps | kill
> 
> and it works.

Nice.


[...]
> I almost *almost* want to write my own custom userland.

Only? Heh... when I was young and foolish, I wanted to trump Linus and
write my own kernel.

But seriously, I *do* contemplate from time to time about writing my own
shell. I have lots of beefs against the way current shells are
implemented, globbing being one of them, or more generally, excessive
implicit interpolation, that turns something simple like \00 into
nonsense like \\\\0000.

My concept of shell is to make it a very thin (but scriptable) layer
over actual syscalls, so you could do something like:

	% open data.txt
	&3: /home/data.txt		# data.txt bound to &3
	% send &3 | grep abc		# pipe data.txt to grep
	abcdef				# output from grep
	% echo @@			# @@ stands for "last output"
	abcdef
	% write &3 @@			# write "abcdef" to data.txt
	% close &3			# detach data.txt

But I haven't actually sat down to think this through, so I don't know
if how practical/usable this will turn out to be. Maybe this will be my
next D project. :P


> But, while I can complain all day about what we have...
> meh it works well enough that I'm in no rush to spend
> a lot of time replacing it.

True.


T

-- 
"The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous


More information about the Digitalmars-d mailing list