[Journal - Command Shells]

Command Shells

Friday, August 19, 2005

Since .NET Console can be used as an interactive interpreter, how does it compare against other command shells? I'll just grab a couple of random points, and compare that against tcsh, which I frequently use.

Repeating things several times:

# tcsh
repeat 5 <command>

// .NET Console
loop(i in 5){<statements>}

.NET Console code is harder to type for the braces and parens. But if you need several commands repeated, you can do so by separating them with semicolons (you'd need a script in tcsh). The loop construct, which is intended for counter loops against ICollection or Int32 expressions (ie., typical for loops), makes for a nice little repeat feature.

For-Each loops, interactive editing:

// .NET Console
foreach(s in Ary.CreateArray("foo", "bar")){<statement-1>; <statement-2>;}

# tcsh
foreach S (foo bar)
foreach? <command-1>
foreach? <command-2>
foreach? end

Nice litte editing feature in tcsh, isn't it? .NET Console requires that you enter the whole construct in one line. Creating lists of values is differs quite a bit obviously, for the fundamental syntactical and type system differences.

Update (Sunday, October 30, 2005): .NET Console allows editing input over multiple lines by using a single trailing backslash at the end of a line (see the CNetConsole.AllowMultiLineInput property).