File: awk

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (88 lines) | stat: -rw-r--r-- 3,034 bytes parent folder | download
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
# (C) 2011 magicant

# Completion script for the "awk" command.
# Supports POSIX 2008, GNU awk 3.1.8, OpenBSD 4.9, NetBSD 5.0.

function completion/awk {

        case $("${WORDS[1]}" --version <>/dev/null 2>&0) in
                (*'GNU Awk'*) typeset type=GNU ;;
                (*)           typeset type="$(uname 2>/dev/null)" ;;
        esac
        case $type in
                (GNU) typeset long=true ;;
                (*)   typeset long= ;;
        esac

        typeset OPTIONS ARGOPT PREFIX
        OPTIONS=( #>#
        "F: ${long:+--field-separator:}; specify the input field separator"
        "f: ${long:+--file:}; specify an AWK source file to execute"
        ) #<#

        if "${WORDS[1]}" -v foo=bar '' <>/dev/null >&0 2>&1; then
                OPTIONS=("$OPTIONS" #>#
                "v: ${long:+--assign:}; specify an assignment to be done during startup"
                ) #<#
        fi

        case $type in
        (GNU)
                OPTIONS=("$OPTIONS" #>#
                "O --optimize; enable optimization"
                "W:"
                "--copyright --copyleft; print copyright info"
                "--dump-variables::; print variables to the specified file"
                "--exec:; specify an AWK source file to execute last"
                "--gen-po; generate PO file"
                "--lint-old; print warnings about non-portable new constructs"
                "--lint::; print warnings about dubious or non-portable constructs"
                "--non-decimal-data; allow octal and hexadecimal numbers"
                "--posix; allow POSIX-compatible constructs only"
                "--profile::; write profiling data to the specified file"
                "--re-interval; allow intervals in regular expressions"
                "--source:; specify AWK source code to execute"
                "--traditional --compat; disable GNU extensions"
                "--use-lc-numeric; use locale's decimal point character"
                "--help --usage"
                "--version"
                ) #<#
                ;;
        (OpenBSD|NetBSD)
                OPTIONS=("$OPTIONS" #>#
                "d::; debug mode"
                "-safe; disable file output, process creation, and accessing environment variables"
                "V; print version info"
                ) #<#
                ;;
        esac

        command -f completion//parseoptions
        case $ARGOPT in
        (-)
                command -f completion//completeoptions
                ;;
        (d)
                ;;
        (F)
                ;;
        (v|--assign)
                ;;
        (W)
                #TODO: -W long option
                ;;
        (--lint) #>>#
                complete -D "treat warnings as errors" fatal
                complete -D "warn about invalid constructs only" invalid
                ;; #<<#
        (--source)
                ;;
        (*)
                complete -P "$PREFIX" -f
                ;;
        esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 et: