bash内置命令是什么_Bash中的内置命令有什么作用?

bash内置命令是什么

bash内置命令是什么

The builtin commands in Bash can be extremely useful, but what does “builtin” itself actually do? Today’s SuperUser Q&A post has the answer to a curious reader’s question.

Bash中的内置命令可能非常有用,但是“内置”本身实际上有什么作用? 今天的“超级用户问答”帖子回答了一个好奇的读者的问题。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader lfalin wants to know what the builtin command in Bash does:

超级用户阅读器lfalin想了解Bash中的内置命令的作用:

I know what a builtin command is, but what does builtin itself do? Executing which ls shows me /bin/ls, but executing which builtin returns nothing. man builtin just gives me a list of builtin commands, one of which is builtin. The rest of the man page explains what a builtin command is, but not what builtin itself is. builtin –help tells me builtin: usage: builtin [shell-builtin [arg …]], but still not what it does. Is it a part of Bash in a way that other builtin commands are not?

我知道一个内置的命令是什么,但到底是什么内建本身呢? 执行哪个ls向我显示/ bin / ls ,但是执行哪个内建函数则不返回任何内容。 man builtin只是给我列出了一些内置命令,其中一个是buildin 。 手册页的其余部分解释了内置的命令是什么,而不是什么内建本身。 Builtin –help告诉我Builtin:用法:Builtin [shell-builtin [arg…]] ,但仍然没有作用。 它是否以其他内置命令无法使用的方式成为Bash的一部分?

What does the builtin command in Bash do?

Bash中的内置命令有什么作用?

答案 (The Answer)

SuperUser contributor Spiff has the answer for us:

超级用户贡献者Spiff为我们提供了答案:

The builtin command makes sure you run the shell built-in version of the command rather than running another command with the same name.

内置命令可确保您运行命令的外壳内置版本,而不是运行具有相同名称的另一个命令。

For example, imagine you defined a shell function named cd to print some extra status every time you change directories, but you messed it up and now you cannot change directories correctly. So now you can type builtin cd ~ to successfully cd back to your home directory without running your broken shell function.

例如,假设您定义了一个名为cd的外壳函数,每次更改目录时都会打印一些额外的状态,但是您搞砸了它,现在您无法正确更改目录。 因此,现在您可以键入内置cd〜来成功将cd返回到主目录,而无需运行损坏的shell函数。

By the way, my copy of the Bash man page has a section called “SHELL BUILTIN COMMANDS”, and it defines the meaning of the builtin command in that section (transcribed below).

顺便说一句,我在Bash手册页的副本中有一个名为“ SHELL BUILTIN COMMANDS”的部分,它在该部分中定义了内置命令的含义(如下所述)。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/323071/what-does-the-builtin-command-in-bash-do/

bash内置命令是什么

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值