Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: strace completion (Re: grouping/joining _values)

On 2008-06-13 at 02:27 +0200, Tomasz Pala wrote:
> I've found solution myself using _wanted and _describe. See attached
> file - it's almost complete strace completion. I think it's ready for
> inclusion into zsh repo.

System calls are OS-specific, as you noted in the TODO; getting the list
involves looking at /usr/include/sys/syscalls but I note that on Linux
that involves having to pull in #include's within that file.  I suspect
that of the Unices today, those which don't include a compiler are
likely to be some Linux variants, default MacOS installs (? not sure,
this one has it but I don't recall if that's because of post-install
work) and ... who knows what else?

Perhaps move the array to a default list, capture a specific set of
defaults in an OS-specific array which can be grabbed with an autoloaded
function if needed, then try to get the real list, the first time, with
cpp?  Unfortunately, SUSv3 only seems to specify that c99(1) exist, not
cpp(1) and I believe that "cpp -dN" is a GCC feature anyway.

Someone with more experience in providing completions may have better
advice, but perhaps:

if [[ -x =gcc ]]; then
  [[ ${#_sys_calls_generated} -eq 0 ]] && _sys_calls_generated=(
    ${${(M)${(@f)"$(gcc -E -dN /usr/include/sys/syscall.h)"}%SYS_*}#SYS_}
elif [[ $OSTYPE == linux-gnu ]]; then
  # ...

Are there any other useful strategies for extracting the real list of
syscalls at runtime, so that on systems which package up the same
version of zsh for N years the list doesn't grow stale?


Messages sorted by: Reverse Date, Date, Thread, Author