Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from nm19-vm3.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from <okiddle@yahoo.co.uk>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(212.82.96.236):SA:0(0.0/5.0):. 
 Processed in 0.695783 secs); 17 Jul 2016 10:23:16 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS,
	T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: okiddle@yahoo.co.uk
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.96.236 as permitted sender)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1468750577; bh=nEoaYLPCuymfz+OxMLbWxxcDHGdBoqbr0aCz/moGefg=; h=From:To:Subject:Date:From:Subject; b=LXghvpdIRg4DhajwUdO920I4iOdM0uvrsO/09BN9ux1twnCE8EuiR14yRUncm7dUdCm1p83AnSGEDpc7X45hxlqav514Z4axwvRMrvrBuAMXjIVsb6WJ96LcGBOHtmOYcNOlwPJ1JoVRCGyoib2KtDR7FUQUDIGWwqMMX3M/HGM/i3qHDRMjt2i2+Gyb9SJk/l83qjT+8QENIPwoFCoWLINvSMOHXJlgc68L0cRp7aSASwsXfRcdwv8aG+Id5bGFsvTwVMJB3SNjq4j/9EGiFug9r+yHSKGv+tCX8Lh2EOc77n6k2nCMQKoR8P5fWgjE3Dkg+VQuDMIBDGszKMY0Wg==
X-Yahoo-Newman-Id: 78042.15739.bm@smtp135.mail.ir2.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: R36udUwVM1n3voJ1sh3dIXwWirC4UrVNZ5wY9hXMdS9lIyO
 tMJd23OEf_DDqnnPzvDycqGWZyx4lU6LS5nohJXZF6MZGyRPPMec8UAfSiJL
 wugcJrnjkRPHCaPXUfoJIIKGPDE15IdyCNX3evCgjRd2kjY8Yg9EZ.O6YjeL
 Acotp9c6b.UIuNkcVyedtndhn9K5Mtn9JhA9qkrhMhVMBWT9Y8MLHf4CaAK5
 HdtnumfMfz2UKlMLw6Iq.W4yZeWz0AIWULITqF3ezgg83C3KjXlj7KDuBsfv
 qMOhelJkF2cwVtkHBLDB6dLzEmuPcOu1y.LmOVtk_xb3zeWNrzSU5SCc6hxw
 dSWu6Zr32PmI20uIlrw4W1DLFW4CNiZriUM4gIcV8OYN5dPFwEHbdHBUXhq9
 vAMmnWhi3sHD6r1srcxdVV9nogce7pdPbFIDFHN2vIff58.YT5ATHVkN0tiE
 zFBhuSVajqExkaareGmSqjjLtS9QZfhwcYa5JcEvV7l7S1b4PNCKHc10MZ5_
 bCOnSQgWJXT0NYYxOUzQkGCHVNkv7Ni6OspXAC4Ox488-
X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI-
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: update strace completion
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <44744.1468749272.1@hydra.kiddle.eu>
Content-Transfer-Encoding: quoted-printable
Date: Sun, 17 Jul 2016 11:54:32 +0200
Message-ID: <44745.1468749272@hydra.kiddle.eu>
X-Seq: zsh-workers 38867

This updates _strace for new options and adds new functions for ltrace
and the more general Unix truss command. I've also factored _sys_calls
out of _strace so _truss can use it. Digging into include files has
replaced the hard coded list of system calls.

Oliver

diff --git a/Completion/Linux/Command/_ltrace b/Completion/Linux/Command/_=
ltrace
new file mode 100644
index 0000000..e48d8ec
--- /dev/null
+++ b/Completion/Linux/Command/_ltrace
@@ -0,0 +1,35 @@
+#compdef ltrace
+
+local root hlp=3D"-h --help -V --version"
+
+(( EUID )) && root=3D'!'
+
+_arguments -s -S $args \
+  "(-c -a --align $hlp)"{-a+,--align=3D}"[align return values in a secifi=
c column]:column [$((COLUMNS*5/8))]" \
+  "(-c $hlp)-A+[specify maximum number of array elements to print]:elemen=
ts" \
+  "(-c -b --no-signals $hlp)"{-b,--no-signals}"[don't print signals]" \
+  "(-a --align -A -b --no-signals -i -n --indent -r -s -t -tt -ttt -T $hl=
p)-c[count time and calls, and report a summary on exit]" \
+  "(-C --demangle $hlp)"{-C,--demangle}'[decode low-level symbol names in=
to user-level names]' \
+  "(-D --debug $hlp)"{-D+,--debug=3D}'[enable debugging]:mask:(help 77)' =
\
+  "($hlp)*-e+[modify which library calls to trace]:filter" \
+  "($hlp)-f[trace child processes]" \
+  "($hlp)*"{-F+,--config=3D}'[load alternate configuration file]:file:_fi=
les' \
+  '(- 1 *)'{-h,--help}'[display help information]' \
+  "(-c $hlp)-i[print instruction pointer at time of call]" \
+  "(-l --library $hlp)"{-l+,--library=3D}'[only trace symbols implemented=
 by specified library]:library:_files' \
+  "($hlp)-L[don't display library calls]" \
+  "(-c -n --indent $hlp)"{-n+,--indent=3D}'[specify indent for each level=
 of call nesting]:spaces' \
+  "(-o --output $hlp)"{-o+,--output=3D}'[write the trace output to specif=
ied file]:file:_files' \
+  "(: $hlp)-p+[attach to the process with specified process ID and begin =
tracing]:process ID:_pids" \
+  "(-c $hlp)-r[print relative timestamps]" \
+  "(-c $hlp)-s+[specify the maximum string size to print]:maximum string =
size [32]" \
+  "($hlp)-S[trace system calls as well as library calls]" \
+  "(-c -ttt $hlp)-t[prefix each line of the trace with the time of day]" =
\
+  "(-c -ttt -tt $hlp)-tt[prefix each line of the trace with the time of d=
ay including the microseconds]" \
+  "(-c -tt -t $hlp)-ttt[prefix each line of the trace with the number of =
seconds and microseconds since the epoch]" \
+  "(-c $hlp)-T[show the time spent in each call]" \
+  "${root}-u+[run as specified user]:user:_users" \
+  '(- 1 *)'{-V,--version}'[display version information]' \
+  "($hlp)*-x+[modify which static functions to trace]:filter" \
+  '(-):command name: _command_names -e' \
+  '*::arguments:_normal'
diff --git a/Completion/Linux/Command/_strace b/Completion/Linux/Command/_=
strace
index d6dabfd..cbf95d6 100644
--- a/Completion/Linux/Command/_strace
+++ b/Completion/Linux/Command/_strace
@@ -1,119 +1,101 @@
-#compdef strace
+#compdef strace strace64
 =

-# TODO:
-#	- make _sys_calls system-dependent
-#	- allow negated calls (e.g. -e!write)
-_sys_calls () {
-	local expl
-	local -a sys_calls
+local curcontext=3D"$curcontext" state line root expl ret=3D1
+typeset -A opt_args
 =

-	sys_calls=3D(_llseek _newselect _sysctl accept access acct
-		adjtimex afs_syscall alarm bdflush bind break brk cacheflush
-		capget capset chdir chmod chown chown32 chroot clone close connect
-		creat create_module delete_module dup dup2 execve exit fchdir
-		fchmod fchown fchown32 fcntl fcntl64 fdatasync flock fork fstat
-		fstat64 fstatfs fsync ftime ftruncate ftruncate64 get_kernel_syms
-		getcwd getdents getdents64 getegid getegid32 geteuid geteuid32
-		getgid getgid32 getgroups getgroups32 getitimer getpagesize getpeername
-		getpmsg getpgid getpgrp getpid getppid getpriority getresgid getresgid3=
2
-		getresuid getresuid32 getrlimit getrusage getsid getsockname getsockopt
-		gettid gettimeofday getuid getuid32 gtty idle init_module ioctl ioperm
-		iopl ipc kill lchown lchown32 link listen lock lseek lstat lstat64
-		madvise mincore mkdir mknod mlock mlockall mmap modify_ldt mount mprote=
ct
-		mpx mremap msync munlock munlockall munmap nanosleep nfsservctl nice
-		oldfstat oldlstat oldolduname oldstat oldumount olduname open pause
-		personality phys pipe pivot_root poll prctl pread prof profil ptrace
-		putpmsg pwrite query_module quotactl read readahead readdir readlink
-		readv reboot recv recvfrom recvmsg rename rmdir rt_sigaction
-		rt_sigpending rt_sigprocmask rt_sigqueueinfo rt_sigreturn rt_sigsuspend
-		rt_sigtimedwait sched_get_priority_max sched_get_priority_min
-		sched_getparam sched_getscheduler sched_rr_get_interval sched_setparam
-		sched_setscheduler sched_yield security select sendfile send sendmsg se=
ndto
-		setdomainname setfsgid setfsgid32 setfsuid setfsuid32 setgid setgid32
-		setgroups setgroups32 sethostname setitimer setpgid setpriority setregi=
d
-		setregid32 setresgid setresgid32 setresuid setresuid32 setreuid setreui=
d32
-		setrlimit setsid setsockopt settimeofday setuid setuid32 setup sgetmask
-		shutdown sigaction sigaltstack signal sigpending sigprocmask sigreturn
-		sigsuspend socket socketcall socketpair ssetmask stat stat64 statfs sti=
me
-		stty swapoff swapon symlink sync sysfs sysinfo syslog time times trunca=
te
-		truncate64 ulimit umask umount uname unlink uselib ustat utime vfork vh=
angup
-		vm86 vm86old wait4 waitpid write writev)
+(( EUID )) && root=3D'!'
 =

-	for t in ${(s:,:)${PREFIX}}; do
-		sys_calls=3D( ${sys_calls:#$t} )
-	done
-	compset -P '*,'
-	_wanted sys_calls expl 'System calls' compadd -qS , -a sys_calls
-}
+_arguments -C -s \
+  '-a+[align return values in a specific column]:column number [40]' \
+  '(-c)-i[print instruction pointer at time of syscall]' \
+  '-o+[write the trace output to the file]:output file:->file-pipe' \
+  '-q[suppress messages about attaching, detaching etc.]' \
+  '(-q)-qq[suppress messages about process exit status]' \
+  '(-c)-r[print a relative timestamp upon entry to each system call]' \
+  '-s+[specify the maximum string size to print]:maximum string size [32]=
' \
+  '(-c -ttt)-t[prefix each line of the trace with the time of day]' \
+  '(-c -ttt -tt)-tt[prefix each line of the trace with the time of day in=
cluding the microseconds]' \
+  '(-c -tt -t)-ttt[prefix each line of the trace with the number of secon=
ds and microseconds since the epoch]' \
+  '(-c)-T[show the time spent in system calls]' \
+  '(-xx)-x[print all non-ASCII strings in hexadecimal string format]' \
+  '(-x)-xx[print all strings in hexadecimal string format]' \
+  '(-c -yy)-y[print paths associated with file descriptor arguments]' \
+  '(-c -y)-yy[print protocol specific information associated with socket =
file descriptors]' \
+  '(-C -i -k -r -ff -t -tt -ttt -T -y -yy)-c[count time, calls, and error=
s for each system call and report a summary]' \
+  '(-c)-C[count time, calls, and errors for each system call and report a=
 summary in addition to regular output]' \
+  '-O+[overhead for tracing system calls]:overhead (microseconds)' \
+  '-S+[sort the output of the histogram (-c option) by the specified crit=
erion]:sort criterion:(time calls name nothing)' \
+  '-w[summarise syscall latency]' \
+  '*-e+[select events to trace or how to trace]:system call:->expressions=
' \
+  '*-P+[trace only system calls accessing given path]:path:_files' \
+  '-b+[detach from process on specified syscall]:syscall:(execve)' \
+  '-f[trace child processes as they are created by currently traced proce=
sses]' \
+  '(-c -C)-ff[write each process trace to <filename>.<pid> (when using -o=
 <filename>]' \
+  '-D[run tracer as detached grandchild, keeping traced process as direct=
 child of calling process]' \
+  '-I+[when strace can be interrupted by signals]:interruptible:((1\:"no =
signals are blocked" 2\:"fatal signals are blocked while decoding syscall =
(default)" 3\:"fatal signals are always blocked (default with -o)" 4\:"fat=
al signals and SIGTSTP are always blocked"))' \
+  '*-E+[set or remove exported environment variable]:variable:->envars' \
+  "${root}-u+[run as specified user]:user:_users" \
+  '(:)*-p+[attach to the process with specified process ID and begin trac=
ing]:process ID:_pids' \
+  '-d[show debug output of strace itself on standard error]' \
+  '-v[print unabbreviated versions of environment, stat, termios, etc. ca=
lls]' \
+  '(- 1 *)-h[display help information]' \
+  '(- 1 *)-V[display version information]' \
+  '(-c)-k[obtain stack trace between each syscall]' \
+  '(-):command name: _command_names -e' \
+  '*::arguments:_normal' && ret=3D0
 =

-_sets () {
-	_alternative \
-		'special:special values:(all none)' \
-		'calls::_sys_calls'
-}
+case $state in
+  expressions)
+    _values -C -S =3D 'qualifying expression' \
+      'trace[trace specified set of system calls only]:system calls:->sys=
calls' \
+      'abbrev[abbreviate the output from printing each member of large st=
ructures]:system call:_sequence _sys_calls -a -n' \
+      'verbose[dereference structures for the specified set of system cal=
ls]:system call:_sequence _sys_calls -a -n' \
+      'raw[print raw, undecoded arguments for the specified set of system=
 calls]:system call:_sequence _sys_calls -a -n' \
+      'signal[trace only the specified subset of signals]:signal:_sequenc=
e _signals -s -M "B\:!=3D"' \
+      'read[perform a full hex and ASCII dump of all the data read from l=
isted file descriptors]:file descriptor:_sequence _file_descriptors' \
+      'write[perform a full hex and ASCII dump of all the data written to=
 listed file descriptors]:file descriptor:_sequence _file_descriptors' && =
ret=3D0
+    if [[ $words[CURRENT] !=3D *=3D* || $state =3D syscalls ]]; then
+      local dedup sets suf=3D"-qS,"
+      compset -P '!'
+      dedup=3D( ${(Ms.,.)PREFIX##*,} ${(Ms.,.)SUFFIX%%,*} )
+      compset -S ',*' || suf=3D""
+      compset -P '*,'
+      sets=3D(
+	'file:trace all system calls which take a file name as an argument'
+	'process:trace all system calls which involve process management'
+	'network:trace all the network related system calls'
+	'signal:trace all signal related system calls'
+	'ipc:trace all IPC related system calls'
+	'desc:trace all file descriptor related system calls'
+	'memory:trace all memory mapping related system calls'
+      )
+      _alternative \
+	"related system call:sets: _describe -t traces 'related system call' set=
s -F dedup $suf" \
+	"system call:syscalls:_sys_calls -a -n $suf -F dedup" && ret=3D0
+    fi
+  ;;
+  file-pipe)
+    compset -P '\\'
+    if (( ! $+opt_args[-ff] )) && compset -P '(!|\|)'; then
+      compset -q
+      if (( CURRENT =3D=3D 1 )); then
+	_command_names -e && ret=3D0
+      else
+	_normal && ret=3D0
+      fi
+    else
+      _files && ret=3D0
+    fi
+  ;;
+  envars)
+    if [[ -prefix *=3D* ]]; then
+      compstate[parameter]=3D"${PREFIX%%\=3D*}"
+      compset -P 1 '*=3D'
+      _value && ret=3D0
+    else
+      _parameters -qS=3D -g "*export*" && ret=3D0
+    fi
+  ;;
+esac
 =

-_traces () {
-	local expl
-	traces=3D('file:trace all system calls which take a file name as an argu=
ment'
-		'process:trace all system calls which involve process management'
-		'network:trace all the network related system calls'
-		'signal:trace all signal related system calls'
-		'ipc:trace all IPC related system calls'
-		'desc:trace all file descriptor related system calls')
-	compset -P '*,'
-	_describe -t traces 'Related system calls' traces -qS ,
-}
-
-_traces_sets () {
-	_alternative \
-		'traces::_traces' \
-		'sets::_sets'
-}
-
-_expression () {
-	_values -S =3D "Qualifying expression" \
-		'trace[trace specified set of system calls only]:system calls:_traces_s=
ets' \
-		'abbrev[abbreviate the output from printing each member of large struct=
ures]:system calls:_sets' \
-		'verbose[dereference structures for the specified set of system calls]:=
system calls:_sets' \
-		'raw[print raw, undecoded arguments for the specified set of system cal=
ls]:system calls:_sets' \
-		'signal[trace only the specified subset of signals]:signal:{compset -P =
"*,"; _signals -s -qS ,}' \
-		'read[perform a full hex and ASCII dump of all the data read from liste=
d file descriptors]:file descriptors:{compset -P "*,"; _file_descriptors -=
qS ,}' \
-		'write[perform a full hex and ASCII dump of all the data written to lis=
ted file descriptors]:file descriptors:{compset -P "*,"; _file_descriptors=
 -qS ,}'
-	if [[ -z "$words[CURRENT]" || -n "${words[CURRENT]:#*=3D*}" ]]; then
-		_traces_sets
-	fi
-}
-
-_arguments \
-	'()-c[count time, calls, and errors for each system call and report a su=
mmary]' \
-	'()-C[count time, calls, and errors for each system call and report a su=
mmary in addition to regular output]' \
-	'-d[show some debugging output of strace itself on the standard error]' =
\
-	'-D[run tracer as detached grandchild, keeping traced process as direct =
child of calling process]' \
-	'-f[trace child processes as they are created by currently traced proces=
ses]' \
-	'-ff[write each process trace to <filename>.<pid> (when using -o <filena=
me>]' \
-	'(-c -d -f -ff -i -q -r -t -tt -ttt -T -v -V -x -xx -a -e -o -O -p -s -S=
 -u -E)-h[print help]' \
-	'-i[print the instruction pointer at the time of the system call]' \
-	'-q[suppress messages about attaching, detaching etc.]' \
-	'-r[print a relative timestamp upon entry to each system call]' \
-	'(-ttt)-t[prefix each line of the trace with the time of day]' \
-	'(-ttt -tt)-tt[prefix each line of the trace with the time of day includ=
ing the microseconds]' \
-	'(-tt -t)-ttt[prefix each line of the trace with the number of seconds a=
nd microseconds since the epoch]' \
-	'-T[show the time spent in system calls]' \
-	'-y[print paths associated with file descriptor arguments]' \
-	'-v[print unabbreviated versions of environment, stat, termios, etc. cal=
ls]' \
-	'(-c -d -f -ff -h -i -q -r -t -tt -ttt -T -v -x -xx -a -e -o -O -p -s -S=
 -u -E)-V[print the version number of strace]' \
-	'(-xx)-x[print all non-ASCII strings in hexadecimal string format]' \
-	'(-x)-xx[print all strings in hexadecimal string format]' \
-	'-I+[when strace can be interrupted by signals]:interruptible:((1\:"no s=
ignals are blocked" 2\:"fatal signals are blocked while decoding syscall (=
default)" 3\:"fatal signals are always blocked (default if '\''-o FILE PRO=
G'\''" 4\:"fatal signals and SIGTSTP are always blocked"))' \
-	'*-P+[trace only system calls accessing given path]:path:_files' \
-	'-a+[align return values in a specific column (default 40)]:column numbe=
r' \
-	'*-e+[select events to trace or how to trace]:system call:_expression' \
-	'-o+[write the trace output to the file]:output file:_files' \
-	'-O+[overhead for tracing system calls]:overhead microseconds' \
-	'(:)-p+[attach to the process with specified process ID and begin tracin=
g]:process ID:_pids' \
-	'-s+[specify the maximum string size to print (default 32)]:maximum stri=
ng size' \
-	'-S+[sort the output of the histogram (-c option) by the specified crite=
rion]:sort by:(time calls name nothing)' \
-	'-u+[run as specified user]:user:_users' \
-	'*-E+[remove variable from the inherited list of environment or define a=
 value]:variable:_printenv' \
-	'(-):command name: _command_names -e' \
-	'*::arguments:_normal'
+return ret
diff --git a/Completion/Unix/Command/_truss b/Completion/Unix/Command/_tru=
ss
new file mode 100644
index 0000000..656c942
--- /dev/null
+++ b/Completion/Unix/Command/_truss
@@ -0,0 +1,76 @@
+#compdef truss
+
+local curcontext=3D"$curcontext" state line expl ret=3D1
+typeset -A opt_args
+local args faults
+
+args=3D(
+  '(-c)-a[show argument strings with exec system call]'
+  '(-a -d -D -e -E -l -r -v -w -x)-c[count traced system calls, signals e=
tc]'
+  '(-c)-d[include timestamps in output]'
+  '(-c)-D[include delta timestamps in output]'
+  '(-c)-e[show environment strings with exec system call]'
+  '-f[follow child processes created after a fork]'
+  '-o+[specify trace output file]:output file:_files'
+)
+
+case $OSTYPE in
+  aix*|solaris*)
+    args+=3D(
+      '(-c)-E[include delta timestamps of time spent within the system ca=
ll]'
+      "-i[don't display interruptible sleeping system calls]"
+      '(-c)-l[include LWP id in each line of output]'
+      '-m+[specify machine faults to trace]: :->faults'
+      '(-c)-r+[show full contents of the I/O buffer for each read()]:file=
 descriptor'
+      '-s+[specify signals to trace]:signal:_sequence _signals -M "B\:!=3D=
"'
+      '-S+[specify signals at which process should be stopped and abandon=
ed]:signal:_sequence _signals -M "B\:!=3D"'
+      '-t+[specify system calls to trace or exclude]:system call:_sequenc=
e _sys_calls -a -M "B\:!=3D"'
+      '-T+[specify system calls at which process should be stopped and ab=
andoned]:system call:_sequence _sys_calls -a -M "B\:!=3D"'
+      '*-u+[user-level function call tracing]: :->userfuncs'
+      '-U+[specify user-level functions at which process should be stoppe=
d and abandoned]: :->userfuncs'
+      '(-c)-v+[enable verbose output of structures for specified system c=
alls]:system call:_sequence _sys_calls -a -M "B\:!=3D"'
+      '(-c)-w+[show full contents of the I/O buffer for each write()]:fil=
e descriptor'
+      '(-c)-x+[enable raw output of structures for specified system calls=
]:system call:_sequence _sys_calls -a'
+      '-p[trace specified existing processes]'
+    )
+  ;;
+  dragonfly*|freebsd*)
+    args+=3D(
+      '-s+[specify the maximum string size to print]:maximum string size =
[32]'
+      "(-c)-S[don't report signals received by the process]"
+      '(*)-p[trace specified existing processes]:pid:_pids'
+    )
+  ;;
+esac
+
+_arguments -C -s : $args \
+  '*::arguments:->args' && ret=3D0
+
+case $state in
+  faults)
+    faults=3D( all ${${${(M)${(f)"$(</usr/include/sys/fault.h)"}:#?define=
[[:blank:]]##FLT*}#*[[:blank:]]FLT}%%[[:blank:]]*} ) 2>/dev/null
+    _sequence _wanted faults expl fault compadd - -M 'B:!=3D' -M 'B:[Ff][=
Ll][Tt]=3D' -M 'm:{a-z}=3D{A-Z}' -a faults && ret=3D0
+  ;;
+  args)
+    if [[ $OSTYPE =3D solaris* ]] && (( $+opt_args[-p] )); then
+      _pids && ret=3D0
+    elif (( CURRENT =3D=3D 1 )); then
+      _command_names -e && ret=3D0
+    else
+      _normal && ret=3D0
+    fi
+  ;;
+  userfuncs)
+    if [[ -prefix *: ]]; then
+      _message -e functions function
+    else
+      compset -P '*,'
+      compset -S '[,:]*'
+      _description -x libs expl lib
+      compadd "$expl[@]" -S '' lib && ret=3D0
+      compadd "$expl[@]" -qS, a.out && ret=3D0
+    fi
+  ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Type/_sys_calls b/Completion/Unix/Type/_sys_c=
alls
new file mode 100644
index 0000000..bd9b34f
--- /dev/null
+++ b/Completion/Unix/Type/_sys_calls
@@ -0,0 +1,20 @@
+#autoload
+
+# Options:
+#
+# -a    add "all" as an additional match
+# -n    add "none" as an additional match
+
+local expl all none
+local ifile=3D/usr/include/sys/syscall.h
+local -au syscalls
+
+zparseopts -D -K -E a=3Dall n=3Dnone
+
+[[ $OSTYPE =3D linux* ]] && ifile=3D/usr/include/bits/syscall.h
+syscalls=3D( ${${${(M)${(f)"$(<$ifile)"}:#?define[[:blank:]]##SYS_*}#*[[:=
blank:]]SYS_}%%[[:blank:]]*} ) 2>/dev/null
+[[ -n $all ]] && syscalls+=3D( all )
+[[ -n $none ]] && syscalls+=3D( none )
+
+_description syscalls expl 'system call'
+compadd "$@" "$expl[@]" -a syscalls

