3 ms·
The first thing to recognise is that is shell is not a special kind of program. It's just a normal executable like everything else. Next, recognise that a shel
by frou_dh 10y ago
The first thing to recognise is that is shell is not a special kind of program. It's just a normal executable like everything else.
Next, recognise that a shell is a language, so you're basically building a commandline programming language interpreter (like python and ruby offer). The difference compared to a general-purpose language is that a shell language traditionally has super-lightweight syntax for operations related to processes and files.
The first step of building a language interpreter is being able to lex (tokenize) and parse a stream of characters.
- dozzie 10y ago> The first thing to recognise is that is shell is not a special kind of program. It's just a normal executable like everything else. Except it works with several OS interfaces touched by very little other programs (terminal mode, terminal's controlling process, process groups, job control), so one has to learn those somehow. > Next, recognise that a shell is a language, so you're basically building a commandline programming language interpreter No, not really. You can have something that just splits line on spaces and executes that as a program and arguments. Calling that a "language" is a quite far stretch. What misled you is that most (all?) of the useful shells are programming languages at the same time as command editors and code executors (in other words, REPL). You just don't see what I described above, because it's awful to work with.
- frou_dh 10y agoI appreciate the elaboration but don't think you've infact refuted anything I said. I originally put "user-mode executable" but edited it to "normal executable" to be more understandable. I don't think it would be a stretch to call space-separated opaque values a language. A very simple one, mind. My answer was directed at someone dipping their toe in who explicitly mentionined that they wanted to make a bash-esque (i.e. non-trivial language) shell.