Log rotation
Jerry Feldman
gaf at blu.org
Sat Aug 4 10:45:22 EDT 2001
Actually ksh does not implement [ as a builtin. It uses [[ as a builtin.
Derek Martin wrote:
> On Sat, Aug 04, 2001 at 07:21:55AM -0400, Jerry Feldman wrote:
> > Note that the [ character is a Unix/Linux command NOT a shell builtin. If
> > you look at /usr/bin on most systems:
> > lrwxrwxrwx 1 root root 4 Jun 3 18:18 [ -> test
>
> While this is true, many modern shells DO implement test as a shell
> builtin. Bash does, as does ksh. IIRC the Bourne shell did not,
> historically, but modern "POSIX" (Bourne-replacement) shells often do,
> because implementing it as a shell built-in is much faster than
> forking and execing a seperate process. I have no idea whether
> Digital Unix's shells do or do not, having no access to such a system.
> See your man page if there's a question. But I'm not really sure why
> this matters...
>
> > So, what that line really is:
> > while test read $line ]; do
>
> This is the same behavior for every bourne-compatible shell, and every
> POSIX-compliant shell that I know of, regardless of whether test is a
> built-in or the executable is used.
>
> > Also note that read is a Unix command, but not a linux command.
> > >From Compaq Tru64 Version 4.0F:
> > -rwxr-xr-x 1 bin bin 1518 Apr 12 1999 /bin/read
> > And remember that the original question was in regard to Digital Unix (eg.
> > Tru64).
>
> This again is shell/system dependent, and again probably irrelevant.
> There's no /bin/read on Linux, probably because all of its shells
> implement the command as a built-in command. Old versions of read
> didn't allow input from redirection, IIRC, but I'm not aware of any
> modern implementations that have this limitation. Otherwise the
> behavior of read is generally the same across POSIX-compliant
> systems/shells.
>
> > Derek Martin wrote:
> >
> > > > while [ read $line ]; do
> > >
> > > This test is always true, because the string "read" contains
> > > characters. However, you haven't asked it to read a line, so the
> > > variable $line is always null for the duration of your script (unless
> > > it inherited a value from the parent shell).
>
> --
> ---------------------------------------------------
> Derek Martin | Unix/Linux geek
> ddm at pizzashack.org | GnuPG Key ID: 0x81CFE75D
> Retrieve my public key at http://pgp.mit.edu
>
--
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org
-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).
More information about the Discuss
mailing list