+ -
当前位置:首页 → 问答吧 → 奇怪的脚本

奇怪的脚本

时间:2011-07-10

来源:互联网

[oracle@perass tools]$ cat 1.sh
#!/bin/echo  Warning:this linrary should be sourced!
#ostype():在当前操作系统中定义了OSTYPE变量
ostype(){
osname=`uname -s`
#假定我们不知道这是什么
OSTYPE=UNKNOWN
case $osname in
"FreeBSD")
OSTYPE="FREEBSD"
echo $OSTYPE
;;
"SunOS") OSTYPE="SOLARIS"
echo $OSTYPE
;;
"Linux") OSTYPE="LINUX"
echo $OSTYPE
;;
esac
}
ostype
[oracle@perass tools]$ ./1.sh
Warning:this linrary should be sourced! ./1.sh

[oracle@perass tools]$ . ./1.sh
LINUX

为什么要不加. 或者source时  会提示这个?
Warning:this linrary should be sourced! ./1.sh

奇怪

作者: 267020090   发布时间: 2011-07-10

因为你的开头就是 "#!/bin/echo  Warning:this linrary should be sourced!”

作者: zooyo   发布时间: 2011-07-10

那为什么会 起作用呢

作者: 267020090   发布时间: 2011-07-10

"#!/bin/echo  Warning:this linrary should be sourced!”

为什么会被调用呢

作者: 267020090   发布时间: 2011-07-10

可能是source吧

作者: zooyo   发布时间: 2011-07-10