zsh-workers
 help / color / mirror / code / Atom feed
2aeeb13b32773db7ba49f771cdab227980fce417 blob 4497 bytes (raw)

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
 
#compdef pr

local curcontext=$curcontext variant msg ret=1
local -a state state_descr line specs optA
typeset -A opt_args

# take care of '+FIRST_PAGE[:LAST_PAGE]' (GNU) or '+FIRST_PAGE' (POSIX)
if _pick_variant -r variant gnu=GNU $OSTYPE --version; then
  msg='FIRST_PAGE[:LAST_PAGE]'
else
  msg='first page'
fi

if [[ $words[CURRENT] = +* ]]; then
  _message "$msg" && return
fi

if (( ! ${words[(I)+[0-9]*]} )); then
  # if +number is not on the command line
  specs=( '(hv)--pages=[specify first and last page numbers]: : _message $msg' )
fi

# common specs
specs+=(
  '(hv -a --across)'{-a,--across}'[with multi-column output, print columns across rather than down]'
  '(hv -d --double-space)'{-d,--double-space}'[double space the output]'
  '(hv -e --expand-tabs)'{-e-,--expand-tabs=-}'[expand tab (or specified char) with specified number of spaces]::number of spaces [8]:->char_number'
  '(hv -h --header -t --omit-header)'{-h+,--header=}'[specify text used in header]:header: '
  '(hv -i --output-tabs)'{-i-,--output-tabs=-}'[replace specified number of spaces with tab (or specified char)]::number of spaces [8]:->char_number'
  '(hv -l --length)'{-l+,--length=}'[specify the page length]:number of lines [66]: '
  '(hv -m --merge)'{-m,--merge}'[print all files in parallel, one in each column]'
  '(hv -n --number-lines)'{-n-,--number-lines=-}'[number lines with specified separator and width]::number of digits [5]:->char_number'
  '(hv -o --indent)'{-o+,--indent=}'[specify left margin]:margin [0]: '
  '(hv -r -no-file-warnings)'{-r,--no-file-warnings}'[omit warning when a file cannot be opened]'
  '(hv -s --separator)'{-s-,--separator=-}'[specify column separator character]:character [tab]: '
  '(hv -t --omit-header -h --header)'{-t,--omit-header}'[omit page headers and trailers]'
  '(hv -w --width)'{-w+,--width=}'[specify page width for multi-column output]:number of characters [72]: '
  '(hv)*: :_files'
)
# XXX: pr accepts -2 -3 -4 ... for specifying the number of columns.
#      Here we offer only -2 and -3, and do so only if there is no
#      -2 -3 -4 ... or --columns on the command line.
if (( ! ${words[(I)-([0-9]##*|-columns*)]} )); then
  specs+=( {-2,-3}'[specify number of columns]' )
fi

if [[ $variant = gnu ]]; then
  # GNU coreutils 8.32
  specs+=(
    '(hv -c --show-control-chars)'{-c,--show-control-chars}'[use hat (^G) and octal backslash notation]'
    '(hv -D --date-format)'{-D+,--date-format=}'[specify format for the header date]: :_date_formats'
    '(hv -f -F --form-feed)'{-f,-F,--form-feed}'[use form feeds instead of newlines to separate pages]'
    '(hv -J --join-lines)'{-J,--join-lines}'[merge full lines in multi-column output]'
    '(hv -N --first-line-number)'{-N+,--first-line-number=}'[specify the line number of the 1st line]:number: '
    '(hv -S --sep-string)'{-S-,--sep-string=-}'[specify column separator string]:string: '
    '(hv -T --omit-pagination)'{-T,--omit-pagination}'[omit page headers and trailers, eliminate any pagination]'
    '(hv -v --show-nonprinting)'{-v,--show-nonprinting}'[use octal backslash notation]'
    '(hv -W --page-width)'{-W+,--page-width=}'[specify page width always]:number of characters [72]: '
  )
  if (( ! ${words[(I)-[0-9]##*]} )); then
    # if -2 -3 -4 ... are not on the command line
    specs+=(
      '(hv)--columns=[specify number of columns]:number of columns: '
      + hv
      '(- *)--help[display help and exit]'
      '(- *)--version[output version information and exit]'
    )
  fi
else
  specs=( ${specs:#(|*\))--*} )    # remove long options
  case $variant in
    freebsd*|dragonfly*|darwin*|netbsd*)
      specs+=(
	'(-f)-F[use form feeds instead of newlines to separate pages]'
	'(-F)-f[same as -F but pause before the 1st page if stdout is terminal]'
	'-p[pause before each page if stdout is terminal]'
      )
      ;|
    freebsd*|dragonfly*|darwin*)
      specs+=( '-L+[specify locale to use]: :_locales' )
      ;;
    openbsd*)
      specs+=( '(-f -F)'{-f,-F}'[use form feeds instead of newlines to separate pages]' )
      ;;
  esac
  optA=( -A '[-+]?*' )  # a single '-' is a valid file name (stdin)
fi

_arguments -C -s -S $optA : $specs && ret=0

case $state in
  char_number)
    # argument for option -e (and -i, -n) can be -e. -e10 or -e.10
    # where . is any non-digit character
    if compset -p 1; then
      _message "$state_descr" && ret=0
    else
      _message "a character [tab] (optional), and $state_descr" && ret=0
    fi
    ;;
esac

return ret
debug log:

solving 2aeeb13b3 ...
found 2aeeb13b3 in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).