Online Book Reader

Home Category

Classic Shell Scripting - Arnold Robbins [213]

By Root 1001 0
-xvf -

... lots of output omitted ...

Start the build process using the AT&T tools by reading which packages are available:$ bin/package read

package: update /home/tolstoy/ksh93/bin/execrate

... lots and lots of output omitted ...

Start the compilation, again using the AT&T tools:$ bin/package make

package: initialize the /home/tolstoy/ksh93/arch/linux.i386 view

... lots and lots and lots of output omitted ...

This step can take quite a while, depending upon the speed of your system and your compiler.

The newly built ksh93 binary is in the file arch/ ARCH /bin/ksh, where ARCH represents the architecture of the machine on which you're building ksh93. For an x86 GNU/Linux system, it's linux.i386. For example:$ arch/linux.i386/bin/ksh

Run newly built ksh93

$ echo ${.sh.version}

Show version

Version M 1993-12-28 p

You may wish to move the newly built Korn shell to a directory in your path, such as your personal bin:$ cp arch/linux.i386/bin/ksh $HOME/bin/ksh93

That's it! Enjoy.

Other Extended Bourne-Style Shells

Two other shells are popular and worthy of note:

The Public Domain Korn Shell

Many of the Open Source Unix-like systems, such as GNU/Linux, come with the Public Domain Korn Shell, pdksh. pdksh is available as source code; start at its home page: http://web.cs.mun.ca/~michael/pdksh/. It comes with instructions for building and installing on various Unix platforms.

pdksh was originally written by Eric Gisin, who based it on Charles Forsyth's public-domain clone of the Version 7 Bourne shell. It is mostly compatible with the 1988 Korn shell and POSIX, with some extensions of its own.

The Z-Shell

zsh is a powerful interactive shell and scripting language with many features found in ksh, bash, and tcsh, as well as several unique features. zsh has most of the features of ksh88 but few of ksh93. It is freely available and should compile and run on just about any modern version of Unix. Ports for other operating systems are also available. The zsh home page is http://www.zsh.org/.

Both of these shells are described in more detail in Learning the Korn Shell (O'Reilly).

Shell Versions

Our exploration of extended shells brings up the good point that it's useful occasionally to be able to find the version number of various shells. Here's how:

$ bash --version

bash

GNU bash, version 3.00.16(1)-release (i686-pc-linux-gnu)

...

$ ksh --version

Recent ksh93 only

version sh (AT&T Labs Research) 1993-12-28 p

$ ksh

Older ksh

$ ^V

Type ^V

$ Version 11/16/88f ksh shows version

$ echo 'echo $KSH_VERSION' | pdksh

pdksh

@(#)PD KSH v5.2.14 99/07/13.2

$ echo 'echo $ZSH_VERSION' | zsh

zsh

4.1.1

There appears to be no way to get a version number from /bin/sh. This is not surprising. Most true Bourne shells on commercial Unix systems are descended from the System V Release 3 (1987) or Release 4 (1989) Bourne shell, and have changed little or not at all since then. Commercial vendors wishing to supply a POSIX-compliant shell generally do so by adapting some version of the Korn shell for that purpose.

Shell Initialization and Termination

In order to support user customization, shells read certain specified files on startup, and for some shells, also on termination. Each shell has different conventions, so we discuss them in separate sections.

If you write shell scripts that are intended to be used by others, you cannot rely on startup customizations. All of the shell scripts that we develop in this book set up their own environment (e.g., the value of $PATH) so that anyone can run them.

Shell behavior depends on whether it is a login shell. When you sit at a terminal and enter a username and password in response to a prompt from the computer, you get a login shell. Similarly, when you use ssh hostname, you get a login shell. However, if you run a shell by name, or implicitly as the command interpreter named in the initial #! line in a script, or create a new workstation terminal window, or run a command in a remote shell with—for example, ssh

Return Main Page Previous Page Next Page

®Online Book Reader