阅读:1109回复:3
shell问题请教。
#!/bin/sh
# $XConsortium: startx.cpp,v 1.4 91/08/22 11:41:29 rws Exp $ # $XFree86: xc/programs/xinit/startx.cpp,v 3.2 1998/12/20 11:58:22 dawes Exp $ # # This is just a sample implementation of a slightly less primitive # interface than xinit. It looks for user .xinitrc and .xserverrc # files, then system xinitrc and xserverrc files, else lets xinit choose # its default. The system xinitrc should probably do things like check # for .Xresources files and merge them in, startup up a window manager, # and pop a clock and serveral xterms. # # Site administrators are STRONGLY urged to write nicer versions. # userclientrc=$HOME/.xinitrc userserverrc=$HOME/.xserverrc sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc clientargs=\"\" serverargs=\"-s 0\" if [ -f $userclientrc ]; then clientargs=$userclientrc else if [ -f $sysclientrc ]; then clientargs=$sysclientrc fi fi if [ -f $userserverrc ]; then serverargs=$userserverrc else if [ -f $sysserverrc ]; then serverargs=$sysserverrc fi fi whoseargs=\"client\" while [ \"x$1\" != \"x\" ]; do #x$1表示什么参数?? case \"$1\" in /\'\'*|\\.*) if [ \"$whoseargs\" = \"client\" ]; then #/‘,,和\\.*表示什么文件类型?? if [ \"x$clientargs\" = x ]; then clientargs=\"$1\" else clientargs=\"$clientargs $1\" fi else if [ \"x$serverargs\" = x ]; then serverargs=\"$1\" else serverargs=\"$serverargs $1\" fi fi ;; --) whoseargs=\"server\" ;; --)表示什么意思??? *) if [ \"$whoseargs\" = \"client\" ]; then clientargs=\"$clientargs $1\" else serverargs=\"$serverargs $1\" fi ;; esac shift done xinit $clientargs -- $serverargs |
|
沙发#
发布于:2002-12-15 01:24
$1代表命令行的第一个参数, 举个例子
gcc -c test.c $0 $1 $2 依此类推, \\.* 指所有以.开始的文件,\\是转义字符 --) 就是说 $1是否和 “--”匹配 |
|
板凳#
发布于:2002-12-15 15:28
$1代表命令行的第一个参数, 举个例子 :P 就是这样的 不过下次提问不要把那么一打断程序都贴出来哦 可以看看LINUX与UNIX SHELL编程指南 机械工业出版社出的那本 确实非常不错 看懂它 SHELL的问题基本就可以搞定了 |
|
地板#
发布于:2002-12-15 15:39
$1代表命令行的第一个参数,这个我是知道的。
while [ \"x$1\" != \"x\" ]; do 的前一行是whoseargs=\"client\" 在while之前并没有执行类似gcc -c test.c。所以 我不知道从这个程序,我可以推导$1等于什么。 |
|