Set the System Ispell Dictionary with select-default-ispell

When several ispell dictionaries are installed, select-default-ispell is the Debian tool that picks the one everyone gets by default. This walks through listing the choices, setting one unambiguous match, and reading a failed match safely. The command comes from dictionaries-common, version 1.29.7 on the machine used for these examples.

Allow about ten minutes. You need a shell, an installed ispell dictionary, and sudo access. The command changes shared dictionary configuration, so use a test or maintenance window if other users or services rely on the host's default.

1. Confirm the command and package

Start with read-only checks that need no elevated privileges:

$ command -v select-default-ispell
/usr/sbin/select-default-ispell
$ dpkg-query -W -f='${Package} ${Version}\n' dictionaries-common
dictionaries-common 1.29.7

The installed program is a Perl wrapper around Debian's dictionary configuration. Its manpage documents three long options: --show-choices, --set-default=regexp, and --debug; there is no short-option equivalent documented for these operations.

Checkpoint: If the package query reports that dictionaries-common is not installed, stop here and install it through your normal package-management process. This guide does not change package state.

2. List the choices without changing the default

Run the choices query as root:

$ sudo select-default-ispell --show-choices
 [one registered choice per line, if any]

Checkpoint: Save one exact choice from your own output as a shell variable, quoted so punctuation or spaces cannot become shell syntax:

$ DICTIONARY='british'
$ printf 'selected pattern: %s\n' "$DICTIONARY"
selected pattern: british

3. Set one unique match

Warning: The next command changes the shared default and invokes update-default-ispell. Review the pattern before pressing Enter. A broad regexp that matches more than one choice will fail rather than silently pick one.

$ sudo select-default-ispell --set-default="$DICTIONARY"
$ printf 'select-default-ispell status: %s\n' "$?"
select-default-ispell status: 0

--set-default first tries a case-sensitive match, then a case-insensitive match, and it must find a single match. Use a more specific regexp when two dictionaries share part of a name:

$ sudo select-default-ispell --set-default='^british$'

Single quotes stop the shell interpreting regexp characters. The command receives ^british$, which matches the complete choice rather than any name containing the word.

4. Check a failed match safely

Test a pattern that cannot match, to see the failure shape without changing the selected dictionary:

$ sudo select-default-ispell --set-default='^__no_such_dictionary__$'
/usr/sbin/select-default-ispell: No (unique) match for "^__no_such_dictionary__$". Aborting ...
$ printf 'status: %s\n' "$?"
status: 255

The exact path in the diagnostic can differ; what matters is the no-match message and the non-zero status. If several installed choices match, the same protection stops an ambiguous selection: tighten the regexp and rerun.

Do not assume every no-match test means dictionaries are broken. When no dictionaries are installed at all, there is nothing to select and the script can finish without applying a selection. Treat an empty choice list as a missing prerequisite, not confirmation of a default.

5. Use the interactive debconf question

Without --set-default, the command forces debconf to ask the shared question for the installed choices:

$ sudo select-default-ispell
[debconf asks you to select the default dictionary]

The prompt and frontend depend on how debconf is configured. On a remote or non-interactive shell, it may fall back to a frontend that cannot open a terminal; in that situation, use the exact non-interactive regexp from step 3, or run the command from a real terminal. Standard output is still reserved for debconf, so read the prompt rather than trying to parse output.

Choosing an item in the prompt changes the same shared setting as the regexp form. To undo the choice, rerun the command with the previously selected dictionary, either as its exact regexp or through the interactive prompt: there is no separate rollback option.

6. Add diagnostics only when needed

--debug enables the program's debug mode. Combine it with a read-only choice inspection when investigating registration or debconf problems:

$ sudo select-default-ispell --debug --show-choices

Expect diagnostic text on standard error and a process status you can capture immediately with printf '%s\n' "$?". Debug mode does not repair a missing dictionary or make an ambiguous regexp unique. Return to the ordinary command once you know the exact choice you need.

Done means