Previous Section  < Day Day Up >  Next Section

9.16. TC Shell Spelling Correction

Spelling correction, a feature added to the TC shell, is the ability to correct spelling errors in filenames, commands, and variables. If using the emacs built-in editor, the spelling error can be corrected by using the spelling correction keys, bound to the Meta-s or Meta-S keys (use the Alt or Esc key if you don't have Meta) and Meta-$ to correct an entire line. The value of the prompt, prompt3, displays the spelling correction prompt.[7]

[7] From the tcsh man page: "Beware: Spelling correction is not guaranteed to work the way one intends, and is provided as an experimental feature. Suggestions and improvements are welcome."

If you are using the vi built-in editor, set the built-in variable correct, and the shell will prompt you to fix the spelling.

Table 9.18. The correct Variable Arguments

Argument

What It Does

all

Spell-corrects entire command line

cmd

Spell-corrects commands

complete

Completes commands


Example 9.93.

1   > fimger[Alt-s]    # Replaces fimger with finger

2   > set correct=all

3   > dite

    CORRECT>date (y|n|e|a)? yes

    Wed Aug 8 19:26:27 PDT 2004

4   > dite

    CORRECT>date (y|n|e|a)? no

    dite: Command not found.

    >

5   > dite

    CORRECT>date (y|n|e|a)? edit

    > dite      # Waits for user to edit and then executes command

6   > dite

    CORRECT>date (y|n|e|a)? abort

    >


EXPLANATION

  1. By pressing the Meta (or Alt or Esc) key together with an s, the spelling of a command, filename, or variable can be corrected. This does not work if you are using the built-in vi editor.

  2. By setting correct to all, tcsh will attempt to correct all spelling errors in the command line. This feature is available for both emacs and vi keybindings.

  3. Because the command was incorrectly spelled, the third prompt, prompt3, "CORRECT>date (y|n|e|a)?" appears on the screen, and the user is supposed to type the letter y if he or she wants the spelling corrected, an n if not, an e if he or she wants to edit the line, or an a if he or she wants to abort the whole operation.

  4. If the user wants the command to be unchanged, he types an n for no.

  5. If the user wants to edit the correction, he or she types an e, and will be prompted to fix or enhance the command.

  6. If the correction is incorrect or not wanted, the user types an a, and the spelling correction is aborted.

    Previous Section  < Day Day Up >  Next Section