Hva gjør det innebygde kommandoen i bash?

Innholdsfortegnelse:

Hva gjør det innebygde kommandoen i bash?
Hva gjør det innebygde kommandoen i bash?

Video: Hva gjør det innebygde kommandoen i bash?

Video: Hva gjør det innebygde kommandoen i bash?
Video: We fixed Windows 10 - Microsoft will HATE this! - YouTube 2024, April
Anonim
De innebygde kommandoene i Bash kan være svært nyttige, men hva gjør "innebygd" i seg selv egentlig? Dagens SuperUser Q & A innlegg har svaret på en nysgjerrig leser spørsmål.
De innebygde kommandoene i Bash kan være svært nyttige, men hva gjør "innebygd" i seg selv egentlig? Dagens SuperUser Q & A innlegg har svaret på en nysgjerrig leser spørsmål.

Dagens Spørsmål & Svar-sesjon kommer til oss med høflighet av SuperUser-en underavdeling av Stack Exchange, en fellesskapsdrevet gruppering av Q & A-nettsteder.

Spørsmålet

SuperUser leser lfalin vil vite hva den innebygde kommandoen i Bash gjør:

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?

Hva gjør den innebygde kommandoen i Bash?

Svaret

SuperUser-bidragsyter Spiff har svaret for oss:

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

Har du noe å legge til forklaringen? Lyder av i kommentarene. Vil du lese flere svar fra andre tech-savvy Stack Exchange-brukere? Sjekk ut hele diskusjonstråden her.

Anbefalt: