bash中的内置命令是做什么的?

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

bash中的内置命令是做什么的?

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

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者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?

Bash中的内置命令是做什么的?

答案

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

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.

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

007Ys3FFgy1gpavolnzvrj30hd06274e


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-07 08:32
  • 阅读 ( 180 )
  • 分类:互联网

你可能感兴趣的文章

什么是shell脚本,为什么要使用它

shell是Linux或Unix操作系统中的一个程序,它允许您输入命令供系统执行。当在linux计算机上打开终端窗口时,它启动shell程序,该程序提供一个输入命令的界面。此接口称为命令行接口。输入命令后,shell将执行该命令,并在屏幕...

  • 发布于 2021-03-13 04:53
  • 阅读 ( 256 )

Windows10中LinuxBashShell快速指南

...,你可以通过一个图形用户界面(GUI)获得传统Ubuntu安装中的所有特性(所有二进制文件)。 ...

  • 发布于 2021-03-17 01:06
  • 阅读 ( 201 )

如何在windows10上获得linux bash shell

... 这是Windows内置的一项功能。与在虚拟机中安装Linux不同,可以从“开始”菜单立即调用Windows子系统for Linux。 ...

  • 发布于 2021-03-21 11:48
  • 阅读 ( 294 )

如何定制mac终端并使其更有用

... 终端窗口的行为与macOS中的任何其他应用程序一样。您可以最小化、移动、调整大小、缩放和滚动内容。在您使用终端任意时间长度后,您键入的命令将产生大量文本。 ...

  • 发布于 2021-03-21 20:13
  • 阅读 ( 282 )

如何使用受限shell来限制linux用户可以做什么

.../”的命令。 调用exec来替换shell的另一个进程。 使用脚本中的任何限制功能。 您可以使用-r(restricted)选项来调用受限制的Bash shell。禁止尝试执行更改工作目录之类的简单任务。一条简短的消息告诉您cd受到限制。 bash -r cd Docu...

  • 发布于 2021-03-31 10:57
  • 阅读 ( 398 )

如何使用shopt定制bashshell

...nts cdspell选项 当cdspell选项打开时,Bash将自动更正目录名中的简单拼写错误和打字错误。 我们键入以下内容来设置cdspell选项: shopt -s cdspell 要尝试更改为小写的目录,该目录应具有大写字母首字母,请键入以下内容: cd documents...

  • 发布于 2021-04-01 12:30
  • 阅读 ( 180 )

如何使用chsh在linux上更改默认shell

...st shell是bash的较轻版本。 破折号:Debian Alquist Shell是Ubuntu中的默认Shell脚本。bash是默认的登录和交互式shell,dash用于运行系统进程,因为它比bash轻得多。 zsh:Z shell是bash shell家族的一个现代版本。它提供了整洁的改进,比如命令...

  • 发布于 2021-04-02 06:04
  • 阅读 ( 344 )

linux下如何使用which命令

...令并启动它。有些命令(如cd、history和pwd)是内置在shell中的,因此Bash不必费劲地查找这些命令。 但是Bash如何定位其他命令、程序和外部独立二进制文件呢?Bash使用路径,实际上是一组路径,每个路径指向一个目录。然后,它...

  • 发布于 2021-04-02 20:07
  • 阅读 ( 183 )

如何在linux上使用chroot命令

...),该文件系统无法与常规文件系统进行交互。chroot环境中的所有内容都被写入和包含。chroot环境中的任何东西都不能在不升级到root权限的情况下看到它自己的、特殊的根目录。这就为这种环境赢得了一个chroot监狱的绰号。术...

  • 发布于 2021-04-03 03:19
  • 阅读 ( 205 )

如何在linux上运行和控制后台进程

...符-with-T选项。 jobs ps T jobs命令告诉我们: [1] :方括号中的数字是作业编号。当我们需要用作业控制命令来控制它时,我们可以使用它来引用作业。 +:加号+表示如果使用没有特定作业编号的作业控制命令,将对该作业执行操...

  • 发布于 2021-04-03 03:30
  • 阅读 ( 236 )
chtz7857
chtz7857

0 篇文章

相关推荐