由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to program a shell extension
相关主题
怎么实现这个alias (转载)android怎么写一个binary command? (转载)
Windows Shell/command for Briefcase?在用C写shell,遇到问题
Questions about MAKEFILE是zsh吗?
How to execute a shell command in java and display the output?[转载] A shell script question. :)
问个php的问题关于shell script的一个问题
怎么在c shell里给file加一行string?Shell script 问题
[合集] Shell script problem?shell script question
help for Shell script commands问个问题.shell/perl
相关话题的讨论汇总
话题: shell话题: extension话题: program话题: so话题: commands
进入Programming版参与讨论
1 (共1页)
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?
1 (共1页)
进入Programming版参与讨论
相关主题
问个问题.shell/perl问个php的问题
expert system shell 现在哪个好些? clips? jess? or ???怎么在c shell里给file加一行string?
关于perl和linux shell script的书最经典有哪些? (转载)[合集] Shell script problem?
printf的问题help for Shell script commands
怎么实现这个alias (转载)android怎么写一个binary command? (转载)
Windows Shell/command for Briefcase?在用C写shell,遇到问题
Questions about MAKEFILE是zsh吗?
How to execute a shell command in java and display the output?[转载] A shell script question. :)
相关话题的讨论汇总
话题: shell话题: extension话题: program话题: so话题: commands