ARF(1) General Commands Manual ARF(1)

arfprompt for a menu selection in the terminal

arf

arf prompts the user to select one of the menu items provided on the standard input by typing a one-letter response and pressing return. Each item has a corresponding hotkey, indicated by parentheses surrounding it. For example, the hotkey for ‘(r)etry’ is ‘r’. The item corresponding to the letter entered is printed on the standard output. If an invalid selection is made, the prompt will be repeated until the user gets the picture.

Each line of input read by arf becomes a menu item, with the first letter in the line becoming the hotkey. If a later item starts with the a letter already used as a hotkey, a subsequent letter will become the hotkey.

If a single letter in a line of input is surrounded by parentheses, that letter will be preferred for the hotkey over the initial letter, but it will still be deconflicted if an earlier input line uses the same letter as a hotkey. Such parentheses are not printed to the standard output when the item is selected, so a menu item input as ‘a(b)ort’ will be printed as ‘abort’ when the user enters ‘b’.

Instead of attempting to be clever when presented with a menu item for which it cannot select a conflict-free hotkey, arf exits in failure to give you a chance to be even cleverer.

The arf utility exits 0 on success, and >0 if an error occurs.

The following lines, used as input to arf, will prompt the user with the menu ‘(a)bort, (r)etry, (f)ail?’:

abort
retry
fail

and these ones will present ‘(a)ttack, (d)efend, (e)at, dela(y), e(x)it’:

attack
defend
eat
dela(y)
exit

The author has vivid childhood memories of the enigmatic, koan-like demand issued by certain computers in times of stress: “Abort, Retry, Fail?”

Evan Silberman <evan@jklol.net>

Menu items with parentheses or commas in them are likely to cause confusion.

Only the first letter of the input line submitted after the prompt is considered, so a keysmash may turn out to be a valid selection.

By letter, I mean any character in one of Unicode's Letter ((L)) categories.

July 1, 2021 OpenBSD 6.9