script 中的 echo 语句是这样的:
echo -e "You SHOULD input 2 numbers, I will cross them!\n"
sh sh04.sh 执行的时候(非预期结果):
tiande@tiande-debian:~/Practice$ sh sh04.sh
-e You SHOULD input 2 numbers, I will cross them!
#这是 \n 的空行
./sh04.sh(或 source sh04.sh)执行的时候(理想结果):
tiande@tiande-debian:~/Practice$ ./sh04.sh
You SHOULD input 2 numbers, I will cross them!
#这是 \n 的空行
然而 bash 并没有什么特殊处理
echo 也未作改变:
tiande@tiande-debian:~/Practice$ type echo
echo 是 shell 内建
把 script 里的 PATH 写到当前 bash 也不行。
测试 script :
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo -e "You SHOULD input 2 numbers, I will cross them! \n"
QUESTION
我只知道 ./sh04.sh (OR sourcesh 04.sh) 是在当前 bash 执行
sh sh04.sh 是 sleep 当前 bash , 启用新 session
但是并没有发现 环境变量 有特别的变化
拉么是拉里粗戳了
求一语道破人生迷思
谢谢 ;)