[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Worth mentioning in documentation
From: |
Greg Wooledge |
Subject: |
Re: Worth mentioning in documentation |
Date: |
Mon, 10 Aug 2015 08:19:25 -0400 |
User-agent: |
Mutt/1.4.2.3i |
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.
- Worth mentioning in documentation, Juanma, 2015/08/06
- Re: Worth mentioning in documentation, Greg Wooledge, 2015/08/06
- Message not available
- Re: Worth mentioning in documentation, Greg Wooledge, 2015/08/07
- Re: Worth mentioning in documentation, Eduardo A . Bustamante López, 2015/08/07
- Re: Worth mentioning in documentation, Juanma, 2015/08/10
- Re: Worth mentioning in documentation,
Greg Wooledge <=
- Re: Worth mentioning in documentation, Bob Proulx, 2015/08/10
- Re: Worth mentioning in documentation, Juanma, 2015/08/11
- Re: Worth mentioning in documentation, Eric Blake, 2015/08/10