- 论坛徽章:
- 0
|
HP-UX环境下Shell程序调试实验教程
找到原因了,请看
/home/oracle/lyc]more new.sh
#!/bin/bash
curr_sh=`ps|grep $$|awk '{print $4}'`
set -x
echo $curr_sh
if [ $curr_sh="bash" ]
then
echo "The current shell is bash."
else
echo "The current shell isn't bash,it's $curr_sh."
fi
echo $curr_sh
/home/oracle/lyc]./new.sh
+ echo new.sh
new.sh
+ '[
']'
+ echo 'The current shell is bash.'
The current shell is bash.
+ echo new.sh
new.sh
/home/oracle/lyc]
这个是修改之前的脚本
经过修改后
/home/oracle/lyc]more new.sh
#!/bin/bash
curr_sh=`ps|grep $$|awk '{print $4}'`
set -x
echo $curr_sh
if [ $curr_sh = "bash" ]
then
echo "The current shell is bash."
else
echo "The current shell isn't bash,it's $curr_sh."
fi
echo $curr_sh
/home/oracle/lyc]./new.sh
+ echo new.sh
new.sh
+ '[' new.sh = bash ']'
+ echo 'The current shell isn'\''t bash,it'\''s new.sh.'
The current shell isn't bash,it's new.sh.
+ echo new.sh
new.sh
/home/oracle/lyc]
两个脚本有什么区别?自己看看
注意等于号=两边的空格,原来是这样的,唉!! |
|