home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeBook TitleSearch this book

1.5. Interactive Shell Use

When you use the shell interactively, you engage in a login session that begins when you log in and ends when you exit or press CTRL-D.[3] During a login session, you type command lines into the shell; these are lines of text ending in ENTER that you type into your terminal or workstation.[4] By default, the shell prompts you for each command with a dollar sign, though, as you will see in Chapter 3 the prompt can be changed.

[3] You can set up your shell so that it doesn't accept CTRL-D, i.e., it requires you to type exit to end your session. We recommend this, because CTRL-D is too easy to type by accident; see the section on options in Chapter 3.

[4] Although we assume that there are few people still using real serial terminals, modern windowing systems provide shell access through a terminal emulator. Thus, at least when it comes to interactive shell use, the term "terminal" applies equally well to a windowing environment.

1.5.2. Built-in Help

Almost all the built-in commands in ksh have both minimal and more extensive "online" help. If you give a command the -? option, it prints a short usage summary:

$ cd -?
Usage: cd [-LP] [directory]
   Or: cd [ options ] old new

(You may wish to quote the ?, since, as we will see later, it is special to the shell.) You may also give the --man option to print help in the form of the traditional Unix man page.[5] The output uses ANSI standard escape sequences to produce a visible change on the screen, rendered here using a bold font:

[5] Starting with ksh93i.

$ cd --man
  cd - change working directory 

  cd [ options ] [directory]
  cd [ options ] old new

  cd changes the current working directory of the current shell environment.

  In the first form with one operand, if directory begins with /, or if the
  first component is . or .., the directory will be changed to this directory.

Similarly, the --html option produces output in HTML format for later rendering with a web browser.

Finally, the --nroff option let's you produce each command's help in the form of nroff -man input.[6] This is convenient for formatting the help for printed output.

[6] All of the help options send their output to standard error (which is described later in this chapter). This means you have to use shell facilities that we don't cover until Chapter 7 to catch their output. For example, cd --man 2>&1 | more runs the online help through the pager program more.

For POSIX compliance, a few commands don't accept these options: echo, false, jobs, login, newgrp, true, and :. For test, you have to type test --man -- to get the online help.

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.