• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

国民时代

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

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..

 

本篇文章出自“国民时代”,转载请注明转载出处。

posted on 2019-04-01 15:43  国民时代  阅读(956)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3