+ -
当前位置:首页 → 问答吧 → 脑筋急转弯儿 - 再请大家试一试

脑筋急转弯儿 - 再请大家试一试

时间:2003-11-17

来源:互联网

上回的小测验吸引了几位兄弟来捧场,多谢了。出题的目的不是想难倒大家,而是想
活跃一下坛子的气氛,对UNIX一些基础的基础有一定的了解。看完了题,回机器上
一试就有结果。知道结果后,最好想想为什么,那我们的目的就达到了。

这回再给大家出个小题目,条件和上回一样,另外请大家看完题目先做题,后看其
它人的帖子:

在shell 工作情况下,请给举个“command"的例子,这个command是一个shell 的"built
in fonction", 而不是一个”system call"。

a. 看完之后张口就出的,得满分(当然要对了)
b. 1分钟内给正确答案的得80分
c. 10分钟内给正确答案的得60分
d. 不知我在说什么的,不及格啦。。。

作者: werix   发布时间: 2003-11-17

cd

作者: KornLee   发布时间: 2003-11-17

cd?

作者: hmqq   发布时间: 2003-11-17

晚了:(
bash
export

作者: hmqq   发布时间: 2003-11-17

libtool

作者: home   发布时间: 2003-11-17

我说javalee老大,这题您不该答得这么快 ;P,您应该在有的兄弟不懂的情况下给大家解释为什么。 现在这题只好换成: 为什么是。。。了? 哈哈。。

作者: werix   发布时间: 2003-11-17

builtin, alias, alloc, bg, bindkey, break, breaksw, builtins, case, cd,
chdir, command, complete, continue, default, dirs, do, done, echo,
echotc, elif, else, end, endif, endsw, esac, eval, exec, exit, export,
false, fc, fg, filetest, fi, for, foreach, getopts, glob, goto, hash,
hashstat, history, hup, if, jobid, jobs, kill, limit, log, login, logout,
ls-F, nice, nohup, notify, onintr, popd, printenv, printf, pushd, pwd,
read, readonly, rehash, repeat, sched, set, setenv, settc, setty, setvar,
shift, source, stop, suspend, switch, telltc, test, then, time, trap,
true, type, ulimit, umask, unalias, uncomplete, unhash, unlimit, unset,
unsetenv, until, wait, where, which, while -- shell builtin commands

作者: upon   发布时间: 2003-11-17

脑筋急转弯儿 ? 你这是手筋直转弯儿 ,哈哈,多谢google

作者: werix   发布时间: 2003-11-17

upon, 你既然耍小聪明,那就给大家讲讲为什么cd 必是built-in fonction, 而不可以是system call 吧。 javalee和hmqq的答案在我眼里最正确,其他功能是跟不同的shell 变化或多或少。。。

作者: werix   发布时间: 2003-11-18

一般来说~~,当你无法判断一个命令是shell内置命令或者系统命令的时候,type可以帮助你!
比如:
$type cd
cd is a shell builtin
$type touch
touch is /bin/touch
比较有趣的是echo,他是个双重身份的命令,
$whereis echo
echo: /bin/echo /usr/share/man/man1/echo.1.gz
$type echo
echo is a shell builtin
$type /bin/echo
/bin/echo is /bin/echo

作者: KornLee   发布时间: 2003-11-18

不明白什么叫 "不是一个\"system call\"" ???

作者: bouzouki   发布时间: 2003-11-18

bouzouki,
问题问到点子上了,这也正是这个题的原意: 什么是built-in fonction? 什么是
system call?

简单的说shell 本身就是一个程序/进程,它还是一个用户跟系统之间的一个界面,
用户通过这个界面输入指令,每一个指令都是由shell 做一个fork,产生新的子进
程,在新的子进程里 执行一下execl, execlp, execle, execv, execvp,所有用execl的都是system call。还有是shell里自己的命令,这些命令不需要用execl,这就是我们所说的shell built-in fonction。 为什么cd 必是 built-in fonction呢?请看man cd (我在最后列出来了)

system call
BSD:
man -s 2 intro

linux:
man -S 2 intro

man fork

man cd
DESCRIPTION
directory is an absolute or relative pathname which becomes the new work-ing directory. The interpretation of a relative pathname by cd depends on the CDPATH environment variable (see below).

Note that cd is implemented as a built-in shell command and not as a stand-alone program. Because each process has its own working directory,

a separate cd utility would have no effect (it would change the directory and exit, leaving the working directory in the parent unchanged). Different shells may implement cd with features different from those described here. Please consult the manual for your specific shell.

作者: werix   发布时间: 2003-11-18

可问题是“system call”是系统调用的意思,无论是否是built-in都需要system call,cd就使用了chdir(),我是不明白怎么会把built-in function和system call作为一对相对的概念?

作者: bouzouki   发布时间: 2003-11-19

概念太简单化了吧???

作者: qing   发布时间: 2003-11-19

我想版主是让大家明白,哪些命令是内部命令,哪些是外部命令。所谓built-in function是在SHELL中已经集成了的命令,而system call则是DOS下所谓的外部命令,对否?

作者: upon   发布时间: 2003-11-21

9 4

作者: werix   发布时间: 2003-11-21

werix版主:
你那个无痛安装贴子中的KDE包是哪里搞来的?OpenBSD光盘中并无此包啊。

作者: upon   发布时间: 2003-11-22

KDE's packages is in the official CD (I buy always the original CD ), you can download them from any obsd mirror website.
As shown: we can easy install them with pkg_add kde*

Hope this can help you.

作者: werix   发布时间: 2003-11-22

How much does the original CD cost? and how do i get it?

I'm downloaging the kde packages from openbsd official sites now.

but which mirror site is the nearest one in our country?

Thank U.

作者: upon   发布时间: 2003-11-22