about summary refs log tree commit diff
path: root/Completion/Unix/Command/_mktemp
blob: 0f66d744ed42c596a6f3dacacd49503f8ef647a8 (plain) (blame)
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
#compdef mktemp gmktemp

local variant
local -a args

_pick_variant -r variant busybox=BusyBox gnu='Free Soft' $OSTYPE --version

args=(
  '(-d --directory)'{-d,--directory}'[make directory instead of file]'
  '(-q --quiet)'{-q,--quiet}'[suppress error messages]'
  '(-u --dry-run)'{-u,--dry-run}'[print file name only]'
)

case $variant in
  ^(dragonfly|darwin)*)
    args+=( '(-p --tmpdir)'{-p+,--tmpdir=}'[make relative to specified directory]: :_directories' )
  ;|
  gnu)
    args+=(
      '--suffix=[append specified suffix to template]:template suffix'
      '(: -)'{-V,--version}'[display version information]'
    )
  ;|
  # Most variants don't support long options (except BusyBox's --help)
  ^(gnu|freebsd*))
    args=( ${args:#((#s)|*\))(\*|)--*} )
  ;|
  gnu|*busybox*)
    args+=( '(: -)--help[display help information]' )
  ;|
  (gnu|*busybox|openbsd|solaris)*)
    args+=(
      '-t[generate template relative to temp dir]'
      '1: :_guard "^-*" "template name"'
    )
  ;;
  (dragonfly|netbsd|freebsd|darwin)*)
    args+=(
      '-t[generate template relative to temp dir using specified prefix]:template prefix'
      '*: :_guard "^-*" "template name"'
    )
  ;;
esac

_arguments -s -S : $args