O que o comando interno no Bash faz?

Índice:

O que o comando interno no Bash faz?
O que o comando interno no Bash faz?

Vídeo: O que o comando interno no Bash faz?

Vídeo: O que o comando interno no Bash faz?
Vídeo: Como Corrigir a Falha de Segurança do Windows e se proteger do ataque de Hackers - YouTube 2024, Abril
Anonim
Os comandos incorporados no Bash podem ser extremamente úteis, mas o que “builtin” em si realmente faz? A postagem de perguntas e respostas do SuperUser de hoje tem a resposta para a pergunta de um leitor curioso.
Os comandos incorporados no Bash podem ser extremamente úteis, mas o que “builtin” em si realmente faz? A postagem de perguntas e respostas do SuperUser de hoje tem a resposta para a pergunta de um leitor curioso.

A sessão de perguntas e respostas de hoje nos é oferecida por cortesia do SuperUser, uma subdivisão do Stack Exchange, um agrupamento de sites de perguntas e respostas conduzido pela comunidade.

A questão

Leitor de superusuário O lfalin quer saber o que o comando interno do Bash faz:

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?

O que o comando interno no Bash faz?

A resposta

O colaborador do SuperUser Spiff tem a resposta para nós:

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

Image
Image

Tem algo a acrescentar à explicação? Som desligado nos comentários. Quer ler mais respostas de outros usuários do Stack Exchange com experiência em tecnologia? Confira o tópico de discussão completo aqui.

Recomendado: