Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11309

Re: Worth mentioning in documentation

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Worth mentioning in documentation
Date 2015-08-10 08:19 -0400
Message-ID <mailman.8068.1439209202.904.bug-bash@gnu.org> (permalink)
References <3156909.AJj7susDjE@debxuan> <2473887.nPWqTkAiyd@debxuan> <20150807122454.GU4309@eeg.ccf.org> <3273328.haPDicsXFC@debxuan>

Show all headers | View raw


On Mon, Aug 10, 2015 at 10:18:52AM +0200, Juanma wrote:
> > [ is an ordinary command (a "shell builtin")
> 
> Here is another point I find confusing: I thought a "shell builtin" didn't
> have a separate binary executable file, like 'cd' (which cd => fail), but
> some of them do have such form (which [ => /usr/bin/[ ; which pwd =>
> /bin/pwd). I also fail to see how 'test' modifies the state of the shell
> itself (like 'cd' does), or why it is "impossible or inconvenient to obtain
> [its functionality] with separate utilities".

Don't use which(1).  Which is an external program, so it has no knowledge
of the shell's builtins, aliases, functions and keywords.  Instead, use
type.

imadev:~$ type cd
cd is a shell builtin
imadev:~$ type [[
[[ is a shell keyword
imadev:~$ type -a test
test is a shell builtin
test is /usr/bin/test
test is /bin/test

Bash implements test as a builtin not because it's necessary, but simply
for efficiency.  Forking a whole process to test whether two strings are
equal would be horribly wasteful.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Worth mentioning in documentation Greg Wooledge <wooledg@eeg.ccf.org> - 2015-08-10 08:19 -0400

csiph-web