Linux命令:builtin
语法:
builtin [shell-builtin [arg ...]]
说明:
明确告诉bash执行的是内建命令,而不是和内建命令同名的函数。这实际就是bash容许用户自定义和builtin命令同名的函数,但是执行时,要区分到底执行的是哪个,默认就是函数啦,前面带上builtin就是执行bash自己的内建命令啦。
如果不是builtin命令,而用builtin执行,则返回非0。或者builtin命令的退出码。
Bash允许用户定义和builtin同名的函数,这有点像c++里的重载,用户自定义函数override内部命令了。
help builtin
1 builtin: builtin [shell-builtin [arg ...]] 2 Execute shell builtins. 3 4 Execute SHELL-BUILTIN with arguments ARGs without performing command 5 lookup. This is useful when you wish to reimplement a shell builtin 6 as a shell function, but need to execute the builtin within the function. 7 8 Exit Status: 9 Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is 10 not a shell builtin..
本篇文章出自“国民时代”,转载请注明转载出处。