Skip to content

The Shell Update

Ritchie Frodomar requested to merge work/ritchie/cli into devel

This merge request expands on the globbing support added in my previous merge request. It addresses issue #8 (closed) by allowing the shell to glob for files in the current working directory. This incidentally created a neat little game mechanic.

New Command-Line Parsing

This refers to how individual commands, like rm and cowsay, parse their command-line arguments. I've added initial API support for type-safe option/flag/argument parsing through the use of .NET's System.CommandLine package. This allows the game to automatically generate help text and handle all the hard parts of command parsing, so you don't have to. You just tell it what to look for and what to run.

While I haven't used it game-wide yet, that will not be the case when this MR is ready for merge. Currently, the rm command uses the new parsing. You can use rm --help to get help text. I've not filled out descriptions yet.

File System Context

The sdsh interpreter, built into Socially Distant's game engine, can now get context from the file system. While this is an internal change, it's important.

Better Escape Sequence Handling

The sdsh parser handles escape sequences in a better way. It will now ignore any backslash sequences it doesn't recognize, treating them as raw text. This allows individual commands and expressions to derive meaning from these backslash sequences, even choosing to ignore them.

Shell Globbing

Next time you're in-game, try running echo * in a terminal. Or, if you're on a Linux system, try it in real life.

You'll see a list of everything in your current working directory.

That's what shell globbing does. When the in-game shell sees a * character, it treats the surrounding text as a file search. Any files it finds will end up being passed as arguments to a command. This lets you delete everything in the current directory.

rm -rf *

Or, delete anything containing the word "Ritchie," case-insensitive. But then I'd be sad.

rm -rf *[Rr][Ii][Tt][Cc][Hh][Ii][Ee]

Yes, I'm serious, that genuinely will work in-game. I'm aware that is not a thing in real-life shells,or at least not bash, and this is actually a bug, but...No. Screw it. It's a feature. I'll document it eventually.

Merge request reports