0% found this document useful (0 votes)
56 views7 pages

LAB Unit 7 Handout

This document discusses shells, signals, and traps in Unix/Linux systems. It begins by explaining what signals are and how processes can trap specific signals. It then discusses the shell programming development cycle of creating specifications, design, coding, testing, and debugging. Finally, it lists and briefly describes 13 common types of shells including Bourne, C, Korn, Bash, and Z shells.

Uploaded by

mojbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views7 pages

LAB Unit 7 Handout

This document discusses shells, signals, and traps in Unix/Linux systems. It begins by explaining what signals are and how processes can trap specific signals. It then discusses the shell programming development cycle of creating specifications, design, coding, testing, and debugging. Finally, it lists and briefly describes 13 common types of shells including Bourne, C, Korn, Bash, and Z shells.

Uploaded by

mojbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter - VII

 Signals and Traps


o Understanding signals
o Trapping signals
o Releasing traps
 Programming Considerations
o Shell programming development cycle
o Optimizing execution time
o Programming best practices

Signals:-
A signal is a message that one process sends to another when some abnormal event
takes place or when it wants the other process to do something. Most of the time, a process
send a signal to a sub process it created. You're undoubtedly already comfortable with the
idea that one process can communicate with another through an I/O pipeline; think of a signal
as another way for processes to communicate with each other. 

There are two or three dozen types of signals, including a few that can be used for whatever
purpose a programmer wishes. Signals have numbers (from 1 to the number of signals the
system supports) and names; we'll use the latter. You can get a list of all the signals on your
system, by name and number, by typing kill -l 

Trap:-

Programs in general can be set up to "trap" specific signals and process them in their
own way. The trap built-in command lets you do this from within a shell script. Trap is most
important for "bullet-proofing" large shell programs so that they react appropriately to
abnormal events-just as programs in any language should guard against invalid input. It's also
important for certain systems programming tasks.
trap –l

Shell Programming Development Cycle:-

The program development cycle is the process of developing an application

– The first step in the cycle is to create program specifications

– The second step in the cycle is to create the program design

– The third step is developing the code, which is written, tested, and debugged

Page 1 of 7
The Programming Shells and its Types:-

I) Shell Defined (Introduction)

In Linux and UNIX, a shell refers to a program that is used to interpret the typed commands
the user sends to the operating system. The closest analogy in Windows is the DOS
Command Prompt. However, unlike in Windows, Linux and UNIX computers allow the user
to choose what shell they would like to use.

II) 13 Types of Shell

1. sh: The Bourne shell, or sh, was the default Unix shell of Unix Version 7, and replaced the
Thompson shell, whose executable file had the same name, sh. It was developed by Stephen
Bourne, of AT&T Bell Laboratories, and was released in 1977 in the Version 7 Unix release
distributed to colleges and universities. It remains a popular default shell for UNIX accounts.
The binary program of the Bourne shell or a compatible program is located at /bin/sh on
most Unix systems, and is still the default shell for the root super user on many current Unix
implementations.

Page 2 of 7
2. ash: The Almquist shell (also known as A Shell or ash) was originally Kenneth Almquist’s
clone of the SVR4-variant of the Bourne shell; it is a fast, small, POSIX-compatible Unix shell
designed to replace the Bourne shell in later BSD distributions. By intention it did not feature
line editing or command history mechanisms originally, because Almquist felt that such
should be moved into the terminal driver. Current variants have emacs and vi modes.

3. dash: Debian Almquist shell (dash) is a POSIX-compliant Unix shell, much smaller than bash.
It requires less disk space but is also less feature rich. dash is a direct descendant of the
NetBSD version of the Almquist Shell (ash). It was ported to Linux by Herbert Xu in early
1997. It was renamed to dash in 2002.dash executes scripts faster than bash and depends on
fewer libraries. It is believed to be more reliable in case of upgrade problems or disk failures.

4. bash: Bash is a Unix shell written for the GNU Project. The name of the actual executable is
bash. Its name is an acronym for Bourne-again shell, a pun on the name of the Bourne shell
(sh) (i.e. “Bourne again” or “born again”), an early and important Unix shell written by

Page 3 of 7
Stephen Bourne and distributed with Version 7 Unix circa 1978. Bash was created in 1987 by
Brian Fox. In 1990 Chet Ramey became the primary maintainer. Bash is the default shell on
most Linux systems as well as on Mac OS X and it can be run on most Unix-like operating
systems.

5. fish: fish is a Unix shell. Its name is an acronym for friendly interactive shell. fish focuses on
interactive use, discoverability, and user friendliness. The design goal of fish is to give the
user a rich set of powerful features in a way that is easy to discover, remember, and use.

6. ksh: The Korn shell (ksh) is a Unix shell which was developed by David Korn (AT&T Bell
Laboratories) in the early 1980s. It is backwards compatible with the Bourne shell and
includes many features of the C shell as well, such as a command history, which was inspired
by the requests of Bell Labs users. The main advantage of ksh over the traditional Unix shell
is in its use as a programming language. Since its conception, several features were gradually
added, while maintaining strong backwards compatibility with the Bourne shell.

7. csh: The C shell (csh) is a Unix shell developed by Bill Joy for the BSD Unix system. It was
originally derived from the 6th Edition Unix /bin/sh (which was the Thompson shell), the

Page 4 of 7
predecessor of the Bourne shell. Its syntax is modeled after the C programming language.
The C shell added many feature improvements over the Bourne shell, such as aliases and
command history. Today, the original C shell is not in wide use on Unix; it has been
superseded by other shells such as the Tenex C shell (tcsh) based on the original C shell
code, but adding filename completion and command line editing, comparable with the Korn
shell (ksh), and the GNU Bourne-Again shell (bash).

8. tcsh: tcsh (pronounced “TC-Shell” or “T-shell”) is a Unix shell based on and compatible with
the C shell (csh). It is essentially the C shell with (programmable) filename completion,
command-line editing, and a few other features.

9. es: The es shell is a command line interpreter that uses a scripting language similar to the rc
shell. It is intended to provide a fully functional programming language as a Unix shell. The
bulk of es’ development occurred in the early 1990s. Unlike other modern shells, es does not
have job control. Patches to provide job control have been offered, but the currently
available ones have memory leak problems.

Page 5 of 7
10. rc: rc is the command line interpreter for Version 10 Unix, Plan 9, and Inferno operating
systems. It resembles the Bourne shell, but its syntax is somewhat simpler. It was created by
Tom Duff, who is better known for an unusual C programming language construct called
Duff’s device.

11. scsh: Scsh is a POSIX API layered on top of the Scheme programming language (currently
only a Scheme 48 implementation exists, but others are planned) in a manner to make the
most of scheme’s capability for scripting. It is limited to 32-bit platforms.

12. sash: Stand-alone shell (sash) is a Unix shell designed for use in recovering from certain
types of system failures. The built in commands of sash have all libraries linked statically, so
unlike most shells, the standard UNIX commands do not rely on external libraries. For
example the copy command (cp) requires linux-gate.so, libc.so, and ld-linux.so when built
from GNU coreutils on Linux. If any of these libraries get corrupted, the coreutils cp
command would not work, however in sash, the built-in command, cp, would be unaffected.

Page 6 of 7
13. zsh: The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a
powerful command interpreter for shell scripting. Zsh can be thought of as an extended
bourne shell with a large number of improvements, including some of the most useful
features of bash, ksh, and tcsh.

Facilities offered by different types of shell

Page 7 of 7

You might also like