ied(1) ied(1)
NAME [Toc] [Back]
ied - input editor and command history for interactive programs
SYNOPSIS [Toc] [Back]
ied [-dirt] [-h file] [-s size] [-p prompt]
[-k charmap] utility [arguments ...]
DESCRIPTION [Toc] [Back]
ied is a utility command that is intended to act as an interface
between the user and an interactive program such as bc, bs, or a
shell, providing most of the line editing and history functionality
found in the Korn shell. ied interprets the utility name as the
command to be executed, and passes arguments as the arguments to the
utility. Subsequent input to utility then has access to editing and
history functions very similar to those provided by ksh.
ied monitors the state of the pty it uses to run the command, and,
whenever the application it is running, changes the state from the
state of the tty when ied started, ied becomes ``transparent''. This
allows programs to do shell escapes to screen-smart programs. In
general, ied should not in any way interfere with any action taken by
any program for which it provides a front end. This includes Korn
shell itself: in this case ied would provide history for any
application that was run by ksh, and ksh would provide its own
independent history. In a useful extreme case, ied can be used as a
front end to the login shell (which might be ksh or csh). In this
case, all applications that use normal line editing gain line editing
and history, sharing a single history. The shell would continue to
have its own independent history if it provides such a mechanism.
When ied is in its transparent mode, no history is saved. In
particular the ex mode of vi does not use normal line editing (rather,
it simulates it) and ied cannot provide history in this case. The
Subject: and address line editing of mailx also cannot be edited with
ied.
Options [Toc] [Back]
Several options and command-line arguments control ied's operation:
-d Debug mode. Print information about the operation
of the program. It is best used to determine if a
program puts ied into transparent mode
unexpectedly.
-h filename Keep the history in a file named filename. If a
file of that name already exists and is a history
file, the latter part of it (the last size lines
as specified by the -s option) is used as the
initial value of the history. If the -h option is
not used, the environment variable IEDHISTFILE is
used to supply the name. If neither are present
Hewlett-Packard Company - 1 - HP-UX 11i Version 2: August 2003
ied(1) ied(1)
an unnamed temporary file is used, and no initial
value is provided.
-i Force interactive mode. Normally ied simply execs
the command to which it is asked to be a front end
when the standard input is not a tty (this allows
aliases to be used for commands used in shells
without interfering with their operation). This
option forces ied to remain as a front end, and
all editing functions are in place. This permits
a utility that behaves differently in interactive
and batch modes to be driven from a pipe or file
in interactive mode. This is particularly useful
in testing commands that make this distinction.
-k charmap charmap is a file of 256 or fewer lines. The line
number in the file is the ordinal of a character
as seen as input by ied, and the character on the
line is the character generated as output (and
also used as editing characters). This allows
remapping of (ordinary) keys such as for a Dvorak
keyboard. Characters must start in column one of
each line, and be represented as 1-4 characters
followed by a space or the new-line character for
the next line. Characters after the space are
ignored as comments. Single-character entries
represent themselves. Two-character entries where
the first character is a circumflex (^) converts
the second character to the corresponding control
character. Two-character sequences where the
first character is backslash (\) use the C
language conventions:
\n newline \s space
\\ escape \0 null
\r return \f form feed
\t tab \v vertical tab
\b backspace
Three- and four-character sequences must be \nn or
\nnn, giving the octal value for the character.
If charmap is less than 256 lines long, the
remaining characters are mapped to themselves.
-p prompt Many commands do not prompt when ready for input.
ied approximates a prompting mechanism for such
commands. This is not always perfectly
successful, but for many commands it helps. In
the worst case, the prompt is interspersed with
output in the wrong location. prompt is a string
Hewlett-Packard Company - 2 - HP-UX 11i Version 2: August 2003
ied(1) ied(1)
as used in the format argument to printf(3S). The
only % conversions that can be included are up to
one instance of %d which is converted to the
sequential number of the command, and any number
of occurrences of %% which is treated as a literal
% character. Prompting is suppressed when ied is
operating in transparent mode.
-r This sets "non-raw" mode. Normally ied uses its
own editing capabilities when reading simple text.
This causes ied to use tty line discipline most of
the time. The disadvantage of the default mode is
that more context switches and general processing
are required. The advantage is that ied is more
transparent. For example, to specifically send an
end-of-file in the non-raw mode requires that the
end-of-file character (usually Ctrl-D) be followed
by a carriage return. Similarly the ``literal
next'' function (Ctrl-V) cannot escape the lineerase
and line-kill functions in non-raw mode.
-s size This option specifies the size of the history
buffer. When ied is started with an existing
history file, approximately the last size lines
are available to the history mechanism (the number
is not guaranteed to be exactly size). Other
lines in the file are retained until such time as
ied is started on that history file and it exceeds
approximately 4K bytes in size, at which time ied
discards older entries at the beginning of the
file until it is near 4 Kbytes in size. Since
this occurs only at startup, history files can
grow to be quite large between restarts. Larger
values of size make the process image larger.
If -s is not specified, the value of the
environment variable IEDHISTSIZE is used. If
neither is specified, a default is used.
-t Set transparent mode. This forces ied to
permanently be in transparent mode (as discussed
above). It is primarily useful with -i for some
classes of automated processing. In particular,
it is useful for driving a command if the command
takes as input what ied would interpret as editing
characters. Thus with the appropriate
combinations of -i and -t, it is possible to drive
an editor such as vi or a screen-smart application
from a batch file.
Hewlett-Packard Company - 3 - HP-UX 11i Version 2: August 2003
ied(1) ied(1)
Should something go wrong with ied, the SIGQUIT signal, repeated 3
times, usually aborts ied. The exception is the case of a fully
transparent application, where ied must be killed from another window
or terminal. This is really relevant only when there is no way to
direct the serviced process to terminate itself.
The editing capabilities of ied are essentially those found in ksh.
Only those that differ from ksh are described below. As in ksh, the
style of editing is determined from the environment variable VISUAL,
or from EDITOR if VISUAL is not specified. The value examined should
end in vi, emacs, or gmacs to specify an editor type. If it does not,
ied does no editing, and history is not accessible.
In vi mode:
J Join lines. Considering the most recently
edited line (which is empty immediately after
a line is sent to the application) to be the
``last line'' of the history, the current
line being displayed from the history is
appended to the end of the last line, and the
position in the history is reset to be at the
last line which is then displayed. A space
is inserted between the old and new text on
the last line. The cursor is left on that
space. Because ied's understanding of line
continuation is minimal, this is useful for
editing long statements.
v Not supported.
V Not supported.
# Sends nothing to the application, but inserts
the line in the history (useful for adding
comments to history file).
<esc>,*,= (Filename expansion). Not supported.
@ Macro expansion. Not supported.
Note however that ksh has a rarely-used
function _ that substitutes words from the
previous line (this is not the macro $_, but
rather an editor command). If a preceding
count is given, it uses the countth word of
the last line. This is much more useful with
ied.
In emacs/gmacs mode:
Hewlett-Packard Company - 4 - HP-UX 11i Version 2: August 2003
ied(1) ied(1)
M-*, M-=, M-<esc> (filename expansion) Not supported.
Note that the command M-. (and it's synonym
M-_) provide the same functionality as the vi
mode _ command.
Macro expansion. Not supported.
^O Although supported, it may not always appear
correctly on the screen. The ^L command can
be used to redraw the line. See below for
the discussion on prompting.
EXAMPLES [Toc] [Back]
Add interactive editing to the bc command:
ied bc
Execute vi on testfile using comands taken from script:
cat script | ied -i -t vi testfile
Note that without the use of ied, vi would misbehave because its
standard input would not be a terminal device. In this case the -t is
not required because vi puts itself in raw mode, but for an
application that does not, -t might be required.
The command line
ied -i -t grep '^x:' data_file | tee x_lines
searches the file data_file for lines beginning with x:, sending one
copy to the terminal and a second to file x_lines, just like the
command line
grep '^x:' data_file | tee x_lines
The difference is that in the command line without ied, grep writes
directly to a pipe, and thus buffers its output. If data_file is very
large and not many lines match the pattern, output to the terminal is
delayed. By using ied, the output of grep goes to a pty instead,
which causes grep to output each line as it is ready.
WARNINGS [Toc] [Back]
Since ied cannot know everything about every application, it is
possible that it can become confused, with either the timing or the
prompt being out of phase with the application. Since the use of ied
is never required, it is the user's choice to determine whether the
application is more usable with or without ied. In general, however,
programs that do not confuse ied are usually also the most likely to
benefit from its use.
Hewlett-Packard Company - 5 - HP-UX 11i Version 2: August 2003
ied(1) ied(1)
ied tries to intuit the currently active prompt when it is not
providing one itself. However, this is not always successful. Even
when it is successful, the timing of ied and the serviced command may
occasionally confuse the output. The ^L commands in both emacs and vi
modes redraw the edit line in a consistent fashion that can be used to
create the next command.
AUTHOR [Toc] [Back]
ied was developed by HP.
SEE ALSO [Toc] [Back]
ksh(1).
Hewlett-Packard Company - 6 - HP-UX 11i Version 2: August 2003 [ Back ] |