-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.1
73 lines (73 loc) · 1.61 KB
/
input.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.Dd $Mdocdate: April 04 2020 $
.Dt INPUT 1
.Os
.Sh NAME
.Nm input
.Nd interactively prompt for user input
.Sh SYNOPSIS
.Nm input
.Op Fl 1
.Op Fl w
.Op Fl c Ar command
.Op Fl p Ar prompt
.Op Fl h Pa file
.Op Fl s Ar size
.Sh DESCRIPTION
The
.Nm
utility interactively prompts for input lines, writing received input to
standard output.
In demarcation to
.Xr read 1
it provides
.Xr readline 3
like line editing and an optional persistent history.
Besides, it continuously prompts for input instead of waiting for a
single input line.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 1
Read a single line from standard input and exit.
.It Fl w
Complete the last word instead of the entire line.
.It Fl c Ar command
Invoke
.Ar command
to retrieve a list of available completion items.
This command is invoked each time the user presses the tab character.
Items must be written to standard output and separated by a newline character.
.It Fl p Ar prompt
Change the default prompt string
.Qq "> "
to
.Ar prompt .
.It Fl h Pa file
Store the editing history in
.Pa file .
By default no editing history is kept.
.It Fl s Ar size
Specify the maximum editing history size.
By default 256 entries are kept.
.El
.Sh EXAMPLES
To write all input entered by the user to a file using a shell script:
.Bd -literal -offset indent
input | while read line; do
echo "${input}" >> somefile.txt
done
.Ed
.Pp
To use
.Nm
as an alternative to
.Xr read 1 :
.Bd -literal -offset indent
name=$(input -1 -p "Enter your name: ")
printf "Hello %s!\n" "$name"
.Ed
.Sh SEE ALSO
.Xr rlwrap 1 ,
.Xr readline 3
.Sh AUTHORS
.An Sören Tempel Aq Mt [email protected]