Creating a new language for coding in is not that difficult, especially if it's based on something established. But how do you make it work in an interactive command line, aka a shell?
The funny thing about modern CLI shells is just how much programming tools you have available right there at your fingertips. In my previous jobs, I often found myself writing effectively single-line scripts in bash to take output and process it in some fashion, then either write it somewhere, or move or copy files, or call another program to process a file... Sometimes some combination of all of these! (Sometimes this used to scare my colleagues...)
But most of the time in a shell, you're running a program, perhaps with some parameters. Like calling up a text editor. I don't want to make this harder to do. But at the same time, there is a need to re-evaluate the distinction between literal text and things like variable substitution.
That's... harder than it sounds...
At first blush, then you'd basically have an interactive programming language. Where common actions are annoying
to type. As a worst case example, why would you want to type call chdir(home$ & "/git/project")
when a simple cd git/project already works. That's definitely a step backwards. On the other hand,
how would do cd git/$NAME without adding string interpolation? For that,
call chdir("git/" & name$) makes sense. But it would need to be more typeable. And solve the
literal strings problem.
What I eventually came up with was that the command line needs two modes: one for typing unquoted literal strings, but also another where literal strings needs to be quoted so that variables could be used. Enter "quoted mode".
At the interactive command line, cd git/projects works just like you would expect. But to use a
variable, well, you type: q cd "git/" & name$. (There are other ways I want to make this even
simpler but they're not part of this step.) However, inside a script that you're running, it defaults
to "quoted" mode, so it would be cd "git/" & name$. Which means if it's just a literal string, you still need
to quote it: cd "git/project".
I don't know how usable this would actually be in practice. The main thing to remember is that string
expressions in general (and variable substitution in particular!) just do not work unless you use quoted mode.
They is explicitly not otherwise supported. That's actually why I chose q as
the prefix to switch to quoted mode - it's a single character that's not hard to type, but also unlikely to be
used by something else.
This also gives executable mode another feature: no escaping. That means whatever you type is what is passed to the command. Modulo some things like how to do multiple lines (I have an idea about that) and how a string is parsed into parameters, because sometimes you need the spaces (which I also have ideas for).
Is this too radical? Some internal commands would automatically switch to quoted mode. Like a while
loop, whatever the notation for that will look like. More details to be worked out.