1# (C) 2010 magicant
2
3# Completion script for the "pr" command.
4# Supports POSIX 2008, GNU coreutils 8.4, FreeBSD 8.1, OpenBSD 4.8, NetBSD 5.0,
5# Mac OS X 10.6.4, SunOS 5.10, HP-UX 11i v3.
6
7function completion/pr {
8
9	case $("${WORDS[1]}" --version 2>/dev/null) in
10		(*'coreutils'*) typeset type=GNU ;;
11		(*)             typeset type="$(uname 2>/dev/null)" ;;
12	esac
13	case $type in
14		(GNU) typeset long=true ;;
15		(*)   typeset long= ;;
16	esac
17
18	typeset OPTIONS POSIXOPTIONS ADDOPTIONS ARGOPT PREFIX
19	POSIXOPTIONS=( #>#
20	"a ${long:+--across}; arrange lines across columns"
21	"d ${long:+--double-space}; double space"
22	"e:: ${long:+--expand-tabs::}; expand tabs into spaces"
23	"F f ${long:+--form-feed}; use form feeds to separate pages"
24	"h: ${long:+--header:}; specify the header string"
25	"i:: ${long:+--output-tabs::}; replace adjacent spaces with tabs"
26	"l: ${long:+--length:}; specify the number of lines per page"
27	"m ${long:+--merge}; print all files in parallel, each in one column"
28	"n:: ${long:+--number-lines::}; print line numbers"
29	"o: ${long:+--indent:}; specify the width of offset preceding each line"
30	"p; pause before printing each page to the terminal"
31	"r ${long:+--no-file-warnings}; don't warn about missing/unreadable files"
32	"s:: ${long:+--separator::}; specify the column separator"
33	"t ${long:+--omit-header}; omit page headers and footers"
34	"w: ${long:+--width:}; specify the line width for multi-column layout"
35	) #<#
36
37	ADDOPTIONS=()
38	case $type in
39	(GNU)
40		ADDOPTIONS=("$ADDOPTIONS" #>#
41		"c --show-control-chars; make unprintable characters visible by caret notation and backslashed octal notation"
42		"D: --date-format:; specify the date format in the header"
43		"J --join-lines; merge full lines"
44		"N: --first-line-number:; specify the number to start counting line numbers from"
45		"S:: --sep-string::; specify a string to separate columns"
46		"T --omit-pagination; like -t, and eliminate form feeds in the input"
47		"v --show-nonprinting; make unprintable characters visible by backslashed octal notation"
48		"W: --page-width:; specify the line width"
49		"--help"
50		"--version"
51		) #<#
52		;;
53	(FreeBSD|Darwin)
54		ADDOPTIONS=("$ADDOPTIONS" #>#
55		"L:; specify the locale"
56		) #<#
57		;;
58	(NetBSD)
59		ADDOPTIONS=("$ADDOPTIONS" #>#
60		"T:; specify the date format in the header"
61		) #<#
62		;;
63	(HP-UX)
64		ADDOPTIONS=("$ADDOPTIONS" #>#
65		"c:; specify the number of columns"
66		) #<#
67		;;
68	esac
69
70	OPTIONS=("$POSIXOPTIONS" "$ADDOPTIONS")
71	unset POSIXOPTIONS ADDOPTIONS
72
73	WORDS=("${WORDS/#+/-}")
74
75	command -f completion//parseoptions ${long:+-es}
76	case $ARGOPT in
77	(-)
78		command -f completion//completeoptions
79		;;
80	([DT]|--date-format)
81		if command -vf completion//completestrftime >/dev/null 2>&1 ||
82				. -AL completion/date; then
83			command -f completion//completestrftime
84		fi
85		;;
86	(L)
87		IFS="
88"
89		complete -P "$PREFIX" -- $(locale -a 2>/dev/null)
90		;;
91	([ceilNnosWw]|--expand-tabs|--output-tabs|--first-line-number|--length|--number-lines|--indent|--separator|--width|--page-width)
92		;;
93	(*)
94		complete -P "$PREFIX" -f
95		;;
96	esac
97
98}
99
100
101# vim: set ft=sh ts=8 sts=8 sw=8 noet:
102