Java – how to build a basic terminal from scratch

I have checked some suggestions or instructions including stack overflow online, but anything I find is overwhelming. I'm not sure where to start If I ignore something obvious, please apologize

I want to know how the terminal works. I want to build one from scratch. I hope to provide any suggestions or suggestions on the materials of the concepts and functions required by the terminal, but I don't just want to link to the source code I found a lot of open source projects, but I found them unstoppable

I want to build my own terminal that can run on OS X, Linux and / or windows (I may use Java but will consider other languages) and finally have a web interface (I want to install my console in my browser). I know this has been completed, but I want to do it myself, so I can understand how it works in detail just for a project to do

What I really want is the starting point of the reading material / tutorial and give me some guidance If this means going back to something more basic than the terminal, I'm happy to do this. Once I have some practical procedures, it will enable me to continue to move towards the main goal

Solution

The idea behind the terminal is an infinite loop that interprets and executes each command Here is an example in Perl:

use strict;
use warnings;

while(<>) {
    system($_);
}

exit 0;

I know Perl is not the simplest language to read (but it must be the fastest to write), but that's all you need to know the above program:

< > read from standard input

system($_) Execute the command (where $is a special Perl variable that works within the loop and represents the currently calculated item, so in our example, it is the given command)

You can try to run the above program and save it on your computer as foo PL, open the terminal and execute Perl foo pl.

So, this is the basic idea I think each language implements the same command system (the name may change, but it may be the same) You can check the man system to see how this command works in C I don't know Java, but I'm sure you have to search for something similar From this starting point, I think you can start to build your own terminal

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>