## 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.1. Commands, Arguments, and Options

Shell command lines consist of one or more words, which are separated on a command line by spaces or TABs. The first word on the line is the command. The rest (if any) are arguments (also called parameters) to the command, which are names of things on which the command will act.

For example, the command line `lpr myfile` consists of the command lpr (print a file) and the single argument myfile. lpr treats myfile as the name of a file to print. Arguments are often names of files, but not necessarily: in the command line `mail billr`, the mail program treats billr as the name of the user to which a message will be sent.

An option is a special type of argument that gives the command specific information on what it is supposed to do. Options usually consist of a dash followed by a letter; we say "usually" because this is a convention rather than a hard-and-fast rule. The command `lpr -h myfile` contains the option -h, which tells lpr not to print the "banner page" before it prints the file.

Sometimes options take their own arguments. For example, `lpr -P hp3si -h myfile` has two options and one argument. The first option is -P hp3si, which means "Send the output to the printer called hp3si." The second option and argument are as above.

### 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
>     NAME
>       cd - change working directory

>     SYNOPSIS
>       cd [ options ] [directory]
>       cd [ options ] old new

>     DESCRIPTION
>       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.

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