F**e 发帖数: 593 | 1 I'm not talking about writing shell scripts but how to program a shell
extension. For example, I want to have a "wsh" (or whatever you name it)
that inherits everything in c-shell and does something extra.
There are plenty of open source shells like tclsh, wish, etc, or even mysql,
sqlite3. Can someone give some basic idea? |
q**1 发帖数: 193 | 2
mysql,
duno what you are talking about, but from your example 'extensions', they
obviously don't inherit *everything* from their shell. for example, type 'ls
' in mysql console will produce error instead of doing what it's supposed to
do under bash/tcsh/...
So, what do you really want? to make your own shell, or just add a console
in your application where you can do something like shell.. For the later
one, you may probably want to check 'VMD', a CompBiol software which has a
console that you
【在 F**e 的大作中提到】 : I'm not talking about writing shell scripts but how to program a shell : extension. For example, I want to have a "wsh" (or whatever you name it) : that inherits everything in c-shell and does something extra. : There are plenty of open source shells like tclsh, wish, etc, or even mysql, : sqlite3. Can someone give some basic idea?
|
F**e 发帖数: 593 | 3 thank for your reply.
I guess mysql is a bad example. What I want is my own shell that first can
duplicate everything in c-shell, so that you enter "myshell", all the shell
behavior remains the same as in c-shell. Then I would add in some of my own
built-in commands.
So first step, how would you replicate a csh/tcsh/bash? |
m*****e 发帖数: 4193 | 4 Copy the code and add your own modifications.
shell
own
【在 F**e 的大作中提到】 : thank for your reply. : I guess mysql is a bad example. What I want is my own shell that first can : duplicate everything in c-shell, so that you enter "myshell", all the shell : behavior remains the same as in c-shell. Then I would add in some of my own : built-in commands. : So first step, how would you replicate a csh/tcsh/bash?
|
q**1 发帖数: 193 | 5 check out this link:
http://home.eol.ca/~parkw/index.html
the author of this link(W.P.) is a regular in several unix technical forums.
he extended some of his own thoughts into bash and his softee is open-source.
HTH
shell
own
【在 F**e 的大作中提到】 : thank for your reply. : I guess mysql is a bad example. What I want is my own shell that first can : duplicate everything in c-shell, so that you enter "myshell", all the shell : behavior remains the same as in c-shell. Then I would add in some of my own : built-in commands. : So first step, how would you replicate a csh/tcsh/bash?
|
F**e 发帖数: 593 | 6 That's right. It's too much to read that code.
I was thinking for system commands, I can just call "system()". For example,
whenever "myshell" reads in some command like "ls", myshell will just call
system("ls")
which produces the same result as you would in /bin/sh.
So this might be a simple solution for system commands. But what about shell
built-in commands, like "set", "foreach", etc. Is there an equivalent call
to execute some shell built-in calls from C program?
I know Tcl extension and |
F**e 发帖数: 593 | 7 BTW, I don't need to worry about the signal handling crap for now. So system
commands and shell built-in commands are pretty much what I need. |
c*****t 发帖数: 1879 | 8 除非你想弄些新的语法,其他的你可以通过 alias 及 path 指定。如果
有安全问题,用 rsh。
system
【在 F**e 的大作中提到】 : BTW, I don't need to worry about the signal handling crap for now. So system : commands and shell built-in commands are pretty much what I need.
|
F**e 发帖数: 593 | 9 thx. can you be a little more specific?
【在 c*****t 的大作中提到】 : 除非你想弄些新的语法,其他的你可以通过 alias 及 path 指定。如果 : 有安全问题,用 rsh。 : : system
|
c*****t 发帖数: 1879 | 10 想必你是想在执行你这个 shell 的时候,已经有一些指令。这个
可以在这个 shell 的 .profile, .cshrc 等修改。或者将你指定
的 directory 放在所有的 path 前,这个只需要在执行那个 shell
的 environmental variable 里改就行,更简单。某些 shell 还
可以锁定哪些 environmental variable 不能被修改。
如果你是从安全角度来看,比如让用户只能看到某些 directory,
只能执行某些指令。这种情况下使用 restricted shell 。这个
你要看各个 restricted shell 的功能。
【在 F**e 的大作中提到】 : thx. can you be a little more specific?
|
k*k 发帖数: 508 | 11 man alias
基本上就是用一个简单的命令名代替一串复杂的 shell command
【在 F**e 的大作中提到】 : thx. can you be a little more specific?
|
q**1 发帖数: 193 | 12 so, you dont want to build your own shell anyway.. haa
Be careful, if you are under bash, aliases dont support
arguments and are deprecated. For that issue, use functions
instead, you can customized many stuff that aliases and
stand-alone scripts do.
【在 F**e 的大作中提到】 : thx. can you be a little more specific?
|