flat assembler
Message board for the users of flat assembler.

Index > Main > How does an CLI interpret scripts?

Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
Hey all, I would like to know how an interpreter (like bash, cmd) interpret scripts (like a batch file) and execute the commands.
I know how the fundamentals of how it is done. But I'd like an in dept description, of the process.

(I require this information for my little shell (CLI) project in currently doing)
Thanks in advance! Very Happy

_________________
meshnix
Post 10 Mar 2010, 23:22
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
MeshNix,

It depends on how complex your CLI script language is.
Post 11 Mar 2010, 07:13
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
Well it's quite straightforward even for complex shells. The only difference is that they have many more features and are much more flexible than simpler ones. It's not about "more black magic".

The basic principle is the same: the script file is read and parsed like an assembler/compiler does, but here, every command is executed "live" as if the user was entering them. It may execute internal commands or external programs. It may also support branching, control statements, read/writing environment variables, its own variables, data structures, etc.
In Unix shells, the script may not be executed by the shell itself. The first line (the shebang) defines the interpreter to be used, which might not be the same shell or even *a* shell, but python or perl.

Start small. For example, only support two internal commands.
Then check how other things are done by reading source code and implementing your own routines.
Post 11 Mar 2010, 10:12
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
baldr,
My shell basically supports commands that allow for data manipulation, like array splices, and things of that sort.

ManOfSteel,
Thanks! I've started designing my shell. My shell basically supports on-line processing, and batch processing. But, I have found few source codes (in assembly). But not that are to complex. Do you know any links where i can find any?
Post 11 Mar 2010, 12:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.