标签:结果 lin 说明 which 循环 str make source 设置
Linux 命令优先级 —— alias、function、内部命令(make)# Makefile内容
all:
@echo "Make Command echo : Hello "
$ which make
/usr/bin/make
$ make
Make Command echo : Hello
#!/bin/bash
function make(){
echo "Function Make echo : Hello"
make
exit
}
执行 source envsetup.sh
$ make
Function Make echo : Hello
Function Make echo : Hello
……
此时可以看到,死循环了,在function make 里面调用的还是function make
$ cat ~/bin/makex
#!/bin/bash
echo "Alias Make echo : Hello"
设置别名:alias make=~/bin/makex
$ make
Alias Make echo : Hello
说明:alias make 的优先级高于command make
#!/bin/bash
echo "Alias Make echo : Hello"
make
$ make
Alias Make echo : Hello
Make Command echo : Hello
alias make 中可以直接调用内部命令make
$ cat ~/bin/makex
#!/bin/bash
function make(){
echo "Function Makex echo : Hello"
command make
}
echo "Alias Make echo : Hello"
make
$ make
Alias Make echo : Hello
Function Makex echo : Hello
Make Command echo : Hello
优先级:alias > function make > 内部命令make
$ cat envsetup.sh
#!/bin/bash
function make(){
echo "Function Make echo : Hello"
command make
}
source envsetup.sh
$ make
Function Make echo : Hello
Make Command echo : Hello
结果:
1、fucntion make 的优先级高于command make
2、在function 中可以调用内部make命令,但是要加上command
Linux 命令优先级 —— alias、function、内部命令(make)
标签:结果 lin 说明 which 循环 str make source 设置
原文地址:http://blog.51cto.com/muyusen/2327747