[systemd-commits] 2 commits - .gitignore Makefile-man.am Makefile.am man/coredumpctl.xml man/systemd-coredumpctl.xml man/systemd.journal-fields.xml shell-completion/bash shell-completion/zsh
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Jun 19 04:47:35 PDT 2014
.gitignore | 2
Makefile-man.am | 9 +
Makefile.am | 10 -
man/coredumpctl.xml | 198 ++++++++++++++++++++++++++++++
man/systemd-coredumpctl.xml | 198 ------------------------------
man/systemd.journal-fields.xml | 4
shell-completion/bash/coredumpctl | 85 ++++++++++++
shell-completion/bash/systemd-coredumpctl | 85 ------------
shell-completion/zsh/_coredumpctl | 36 +++++
shell-completion/zsh/_systemd-coredumpctl | 36 -----
10 files changed, 334 insertions(+), 329 deletions(-)
New commits:
commit 61b3b1b8bc9f09e087524074cd04b59402089d01
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jun 19 13:47:07 2014 +0200
build-sys: run forgotten 'make update-man-list'
diff --git a/Makefile-man.am b/Makefile-man.am
index 938e2c3..0535848 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -193,6 +193,7 @@ MANPAGES_ALIAS += \
man/systemd-hybrid-sleep.service.8 \
man/systemd-initctl.8 \
man/systemd-initctl.socket.8 \
+ man/systemd-journald-dev-log.socket.8 \
man/systemd-journald.8 \
man/systemd-journald.socket.8 \
man/systemd-kexec.service.8 \
@@ -295,6 +296,7 @@ man/systemd-hibernate.service.8: man/systemd-suspend.service.8
man/systemd-hybrid-sleep.service.8: man/systemd-suspend.service.8
man/systemd-initctl.8: man/systemd-initctl.service.8
man/systemd-initctl.socket.8: man/systemd-initctl.service.8
+man/systemd-journald-dev-log.socket.8: man/systemd-journald.service.8
man/systemd-journald.8: man/systemd-journald.service.8
man/systemd-journald.socket.8: man/systemd-journald.service.8
man/systemd-kexec.service.8: man/systemd-halt.service.8
@@ -559,6 +561,9 @@ man/systemd-initctl.html: man/systemd-initctl.service.html
man/systemd-initctl.socket.html: man/systemd-initctl.service.html
$(html-alias)
+man/systemd-journald-dev-log.socket.html: man/systemd-journald.service.html
+ $(html-alias)
+
man/systemd-journald.html: man/systemd-journald.service.html
$(html-alias)
commit f4bab1690ebb7bb01ea2d89f92bffd26c04b61ee
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jun 19 13:46:01 2014 +0200
coredump: coredumpctl is so useful now, make it a first-class citizen
Drop the "systemd-" prefix, renaming it from "systemd-coredumpctl" to
"coredumpctl".
diff --git a/.gitignore b/.gitignore
index 97cefb5..66fa09d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@
/busctl
/cdrom_id
/collect
+/coredumpctl
/coverage/
/defined
/exported
@@ -56,7 +57,6 @@
/systemd-cgroups-agent
/systemd-cgtop
/systemd-coredump
-/systemd-coredumpctl
/systemd-cryptsetup
/systemd-cryptsetup-generator
/systemd-dbus1-generator
diff --git a/Makefile-man.am b/Makefile-man.am
index 03adc7c..938e2c3 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -658,7 +658,7 @@ endif
if ENABLE_COREDUMP
MANPAGES += \
- man/systemd-coredumpctl.1
+ man/coredumpctl.1
MANPAGES_ALIAS += \
#
@@ -1477,6 +1477,7 @@ EXTRA_DIST += \
man/bootctl.xml \
man/bootup.xml \
man/busctl.xml \
+ man/coredumpctl.xml \
man/crypttab.xml \
man/daemon.xml \
man/halt.xml \
@@ -1569,7 +1570,6 @@ EXTRA_DIST += \
man/systemd-cat.xml \
man/systemd-cgls.xml \
man/systemd-cgtop.xml \
- man/systemd-coredumpctl.xml \
man/systemd-cryptsetup-generator.xml \
man/systemd-cryptsetup at .service.xml \
man/systemd-delta.xml \
diff --git a/Makefile.am b/Makefile.am
index bd33138..d7fa9da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3706,22 +3706,22 @@ systemd_coredump_LDADD += \
libsystemd-acl.la
endif
-systemd_coredumpctl_SOURCES = \
+coredumpctl_SOURCES = \
src/journal/coredumpctl.c
-systemd_coredumpctl_LDADD = \
+coredumpctl_LDADD = \
libsystemd-journal-internal.la \
libsystemd-internal.la \
libsystemd-shared.la
bin_PROGRAMS += \
- systemd-coredumpctl
+ coredumpctl
dist_bashcompletion_DATA += \
- shell-completion/bash/systemd-coredumpctl
+ shell-completion/bash/coredumpctl
dist_zshcompletion_DATA += \
- shell-completion/zsh/_systemd-coredumpctl
+ shell-completion/zsh/_coredumpctl
sysctl_DATA = \
sysctl.d/50-coredump.conf
diff --git a/man/coredumpctl.xml b/man/coredumpctl.xml
new file mode 100644
index 0000000..159fabb
--- /dev/null
+++ b/man/coredumpctl.xml
@@ -0,0 +1,198 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+ This file is part of systemd.
+
+ Copyright 2012 Zbigniew JÄdrzejewski-Szmek
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<refentry id="coredumpctl" conditional='ENABLE_COREDUMP'
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <refentryinfo>
+ <title>coredumpctl</title>
+ <productname>systemd</productname>
+
+ <authorgroup>
+ <author>
+ <contrib>Developer</contrib>
+ <firstname>Zbigniew</firstname>
+ <surname>JÄdrzejewski-Szmek</surname>
+ <email>zbyszek at in.waw.pl</email>
+ </author>
+ </authorgroup>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>coredumpctl</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>coredumpctl</refname>
+ <refpurpose>Retrieve coredumps from the journal</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>coredumpctl</command>
+ <arg choice="opt" rep="repeat">OPTIONS</arg>
+ <arg choice="req">COMMAND</arg>
+ <arg choice="opt" rep="repeat">PID|COMM|EXE|MATCH</arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para><command>coredumpctl</command> may be used to
+ retrieve coredumps from
+ <citerefentry><refentrytitle>systemd-journald</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>Options</title>
+
+ <para>The following options are understood:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-F</option></term>
+ <term><option>--field=</option></term>
+
+ <listitem><para>Print all possible
+ data values the specified field
+ takes in matching coredump entries of the
+ journal.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-o</option></term>
+ <term><option>--output=FILE</option></term>
+
+ <listitem><para>Write the core to
+ <option>FILE</option>.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--no-legend</option></term>
+
+ <listitem><para>Do not print the column headers.
+ </para></listitem>
+ </varlistentry>
+
+ <xi:include href="standard-options.xml" xpointer="help" />
+ <xi:include href="standard-options.xml" xpointer="version" />
+ <xi:include href="standard-options.xml" xpointer="no-pager" />
+ </variablelist>
+
+ <para>The following commands are understood:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><command>list</command></term>
+
+ <listitem><para>List coredumps captured in the journal
+ matching specified characteristics.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><command>dump</command></term>
+
+ <listitem><para>Extract the last coredump
+ matching specified characteristics.
+ The coredump will be written on standard output,
+ unless an output file is specified with
+ <option>-o/--output</option>.
+ </para></listitem>
+ </varlistentry>
+
+
+ <varlistentry>
+ <term><command>gdb</command></term>
+
+ <listitem><para>Invoke the GNU
+ debugger on the last coredump matching
+ specified characteristics.
+ </para></listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </refsect1>
+
+ <refsect1>
+ <title>Matching</title>
+
+ <para>Match can be:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><replaceable>PID</replaceable></term>
+
+ <listitem><para>Process ID of the
+ process that dumped
+ core. An integer.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>COMM</replaceable></term>
+
+ <listitem><para>Name of the executable
+ (matches <option>COREDUMP_COMM=</option>).
+ Must not contain slashes.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>EXE</replaceable></term>
+
+ <listitem><para>Path to the executable
+ (matches <option>COREDUMP_EXE=</option>).
+ Must contain at least one slash.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><replaceable>MATCH</replaceable></term>
+
+ <listitem><para>General journalctl predicates
+ (see <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>).
+ Must contain an equals sign.
+ </para></listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>Exit status</title>
+ <para>On success, 0 is returned; otherwise, a non-zero failure
+ code is returned. Not finding any matching coredumps is treated
+ as failure.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>See Also</title>
+ <para>
+ <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+ </para>
+ </refsect1>
+
+</refentry>
diff --git a/man/systemd-coredumpctl.xml b/man/systemd-coredumpctl.xml
deleted file mode 100644
index 092ec56..0000000
--- a/man/systemd-coredumpctl.xml
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version='1.0'?> <!--*-nxml-*-->
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-
-<!--
- This file is part of systemd.
-
- Copyright 2012 Zbigniew JÄdrzejewski-Szmek
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
--->
-
-<refentry id="systemd-coredumpctl" conditional='ENABLE_COREDUMP'
- xmlns:xi="http://www.w3.org/2001/XInclude">
-
- <refentryinfo>
- <title>systemd-coredumpctl</title>
- <productname>systemd</productname>
-
- <authorgroup>
- <author>
- <contrib>Developer</contrib>
- <firstname>Zbigniew</firstname>
- <surname>JÄdrzejewski-Szmek</surname>
- <email>zbyszek at in.waw.pl</email>
- </author>
- </authorgroup>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>systemd-coredumpctl</refentrytitle>
- <manvolnum>1</manvolnum>
- </refmeta>
-
- <refnamediv>
- <refname>systemd-coredumpctl</refname>
- <refpurpose>Retrieve coredumps from the journal</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>systemd-coredumpctl</command>
- <arg choice="opt" rep="repeat">OPTIONS</arg>
- <arg choice="req">COMMAND</arg>
- <arg choice="opt" rep="repeat">PID|COMM|EXE|MATCH</arg>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
-
- <para><command>systemd-coredumpctl</command> may be used to
- retrieve coredumps from
- <citerefentry><refentrytitle>systemd-journald</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
-
- <para>The following options are understood:</para>
-
- <variablelist>
- <varlistentry>
- <term><option>-F</option></term>
- <term><option>--field=</option></term>
-
- <listitem><para>Print all possible
- data values the specified field
- takes in matching coredump entries of the
- journal.</para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><option>-o</option></term>
- <term><option>--output=FILE</option></term>
-
- <listitem><para>Write the core to
- <option>FILE</option>.</para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><option>--no-legend</option></term>
-
- <listitem><para>Do not print the column headers.
- </para></listitem>
- </varlistentry>
-
- <xi:include href="standard-options.xml" xpointer="help" />
- <xi:include href="standard-options.xml" xpointer="version" />
- <xi:include href="standard-options.xml" xpointer="no-pager" />
- </variablelist>
-
- <para>The following commands are understood:</para>
-
- <variablelist>
- <varlistentry>
- <term><command>list</command></term>
-
- <listitem><para>List coredumps captured in the journal
- matching specified characteristics.</para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><command>dump</command></term>
-
- <listitem><para>Extract the last coredump
- matching specified characteristics.
- The coredump will be written on standard output,
- unless an output file is specified with
- <option>-o/--output</option>.
- </para></listitem>
- </varlistentry>
-
-
- <varlistentry>
- <term><command>gdb</command></term>
-
- <listitem><para>Invoke the GNU
- debugger on the last coredump matching
- specified characteristics.
- </para></listitem>
- </varlistentry>
-
- </variablelist>
-
- </refsect1>
-
- <refsect1>
- <title>Matching</title>
-
- <para>Match can be:</para>
-
- <variablelist>
- <varlistentry>
- <term><replaceable>PID</replaceable></term>
-
- <listitem><para>Process ID of the
- process that dumped
- core. An integer.</para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><replaceable>COMM</replaceable></term>
-
- <listitem><para>Name of the executable
- (matches <option>COREDUMP_COMM=</option>).
- Must not contain slashes.
- </para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><replaceable>EXE</replaceable></term>
-
- <listitem><para>Path to the executable
- (matches <option>COREDUMP_EXE=</option>).
- Must contain at least one slash.
- </para></listitem>
- </varlistentry>
-
- <varlistentry>
- <term><replaceable>MATCH</replaceable></term>
-
- <listitem><para>General journalctl predicates
- (see <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>).
- Must contain an equals sign.
- </para></listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>Exit status</title>
- <para>On success, 0 is returned; otherwise, a non-zero failure
- code is returned. Not finding any matching coredumps is treated
- as failure.
- </para>
- </refsect1>
-
- <refsect1>
- <title>See Also</title>
- <para>
- <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- </para>
- </refsect1>
-
-</refentry>
diff --git a/man/systemd.journal-fields.xml b/man/systemd.journal-fields.xml
index 6eeb6e3..472a085 100644
--- a/man/systemd.journal-fields.xml
+++ b/man/systemd.journal-fields.xml
@@ -459,7 +459,7 @@
messages containing coredumps from
system and session units.
See
- <citerefentry><refentrytitle>systemd-coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
+ <citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
</para>
</listitem>
</varlistentry>
@@ -597,7 +597,7 @@
<citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd-coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/shell-completion/bash/coredumpctl b/shell-completion/bash/coredumpctl
new file mode 100644
index 0000000..e23152d
--- /dev/null
+++ b/shell-completion/bash/coredumpctl
@@ -0,0 +1,85 @@
+# coredumpctl(1) completion -*- shell-script -*-
+#
+# This file is part of systemd.
+#
+# Copyright 2010 Ran Benita
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# systemd is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with systemd; If not, see <http://www.gnu.org/licenses/>.
+
+__contains_word () {
+ local w word=$1; shift
+ for w in "$@"; do
+ [[ $w = "$word" ]] && return
+ done
+}
+
+__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
+ ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE
+ _{P,U,G}ID _COMM _EXE _CMDLINE
+ _AUDIT_{SESSION,LOGINUID}
+ _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
+ _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
+ _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
+ _KERNEL_{DEVICE,SUBSYSTEM}
+ _UDEV_{SYSNAME,DEVNODE,DEVLINK}
+ __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
+_coredumpctl() {
+ local i verb comps
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+ local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field'
+
+ local -A VERBS=(
+ [LIST]='list'
+ [DUMP]='dump gdb'
+ )
+
+ if __contains_word "$prev" '--output -o'; then
+ comps=$( compgen -A file -- "$cur" )
+ compopt -o filenames
+ elif __contains_word "$prev" '--FIELD -F'; then
+ comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
+ elif [[ $cur = -* ]]; then
+ comps=${OPTS}
+ elif __contains_word "$prev" ${VERBS[*]} &&
+ ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
+ compopt -o nospace
+ COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
+ return 0
+ elif [[ $cur = *=* ]]; then
+ mapfile -t field_vals < <(coredumpctl -F "${prev%=}" 2>/dev/null)
+ COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
+ return 0
+ elif [[ $prev = '=' ]]; then
+ mapfile -t field_vals < <(coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
+ comps=${field_vals[*]}
+ else
+ for ((i=0; i <= COMP_CWORD; i++)); do
+ if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
+ verb=${COMP_WORDS[i]}
+ break
+ fi
+ done
+
+ if [[ -z $verb ]]; then
+ comps=${VERBS[*]}
+ elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
+ comps=''
+ fi
+ fi
+
+ COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
+ return 0
+}
+
+complete -F _coredumpctl coredumpctl
diff --git a/shell-completion/bash/systemd-coredumpctl b/shell-completion/bash/systemd-coredumpctl
deleted file mode 100644
index 805e848..0000000
--- a/shell-completion/bash/systemd-coredumpctl
+++ /dev/null
@@ -1,85 +0,0 @@
-# systemd-coredumpctl(1) completion -*- shell-script -*-
-#
-# This file is part of systemd.
-#
-# Copyright 2010 Ran Benita
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# systemd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-
-__contains_word () {
- local w word=$1; shift
- for w in "$@"; do
- [[ $w = "$word" ]] && return
- done
-}
-
-__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
- ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE
- _{P,U,G}ID _COMM _EXE _CMDLINE
- _AUDIT_{SESSION,LOGINUID}
- _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
- _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
- _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
- _KERNEL_{DEVICE,SUBSYSTEM}
- _UDEV_{SYSNAME,DEVNODE,DEVLINK}
- __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
-_coredumpctl() {
- local i verb comps
- local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
- local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field'
-
- local -A VERBS=(
- [LIST]='list'
- [DUMP]='dump gdb'
- )
-
- if __contains_word "$prev" '--output -o'; then
- comps=$( compgen -A file -- "$cur" )
- compopt -o filenames
- elif __contains_word "$prev" '--FIELD -F'; then
- comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
- elif [[ $cur = -* ]]; then
- comps=${OPTS}
- elif __contains_word "$prev" ${VERBS[*]} &&
- ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
- compopt -o nospace
- COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
- return 0
- elif [[ $cur = *=* ]]; then
- mapfile -t field_vals < <(systemd-coredumpctl -F "${prev%=}" 2>/dev/null)
- COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
- return 0
- elif [[ $prev = '=' ]]; then
- mapfile -t field_vals < <(systemd-coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
- comps=${field_vals[*]}
- else
- for ((i=0; i <= COMP_CWORD; i++)); do
- if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
- verb=${COMP_WORDS[i]}
- break
- fi
- done
-
- if [[ -z $verb ]]; then
- comps=${VERBS[*]}
- elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
- comps=''
- fi
- fi
-
- COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
- return 0
-}
-
-complete -F _coredumpctl systemd-coredumpctl
diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl
new file mode 100644
index 0000000..d13bc70
--- /dev/null
+++ b/shell-completion/zsh/_coredumpctl
@@ -0,0 +1,36 @@
+#compdef coredumpctl
+
+_coredumpctl_command(){
+ local -a _coredumpctl_cmds
+ _coredumpctl_cmds=(
+ 'list:List available coredumps'
+ 'dump:Print coredump to stdout'
+ 'gdb:Start gdb on a coredump'
+ )
+ if (( CURRENT == 1 )); then
+ _describe -t commands 'coredumpctl command' _coredumpctl_cmds
+ else
+ local curcontext="$curcontext"
+ local -a _dumps
+ cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
+ if (( $#cmd )); then
+ # user can set zstyle ':completion:*:*:coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
+ _dumps=( "${(foa)$(coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
+ if [[ -n "$_dumps" ]]; then
+ _describe -t pids 'coredumps' _dumps
+ else
+ _message "no coredumps"
+ fi
+ else
+ _message "no more options"
+ fi
+ fi
+}
+
+_arguments \
+ {-o+,--output=}'[Write output to FILE]:output file:_files' \
+ {-F+,--field=}'[Show field in list output]:field' \
+ '--no-pager[Do not pipe output into a pager]' \
+ {-h,--help}'[Show this help]' \
+ '--version[Show package version]' \
+ '*::coredumpctl commands:_coredumpctl_command'
diff --git a/shell-completion/zsh/_systemd-coredumpctl b/shell-completion/zsh/_systemd-coredumpctl
deleted file mode 100644
index 94b1e92..0000000
--- a/shell-completion/zsh/_systemd-coredumpctl
+++ /dev/null
@@ -1,36 +0,0 @@
-#compdef systemd-coredumpctl
-
-_systemd-coredumpctl_command(){
- local -a _systemd_coredumpctl_cmds
- _systemd_coredumpctl_cmds=(
- 'list:List available coredumps'
- 'dump:Print coredump to stdout'
- 'gdb:Start gdb on a coredump'
- )
- if (( CURRENT == 1 )); then
- _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds
- else
- local curcontext="$curcontext"
- local -a _dumps
- cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
- if (( $#cmd )); then
- # user can set zstyle ':completion:*:*:systemd-coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
- _dumps=( "${(foa)$(systemd-coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
- if [[ -n "$_dumps" ]]; then
- _describe -t pids 'coredumps' _dumps
- else
- _message "no coredumps"
- fi
- else
- _message "no more options"
- fi
- fi
-}
-
-_arguments \
- {-o+,--output=}'[Write output to FILE]:output file:_files' \
- {-F+,--field=}'[Show field in list output]:field' \
- '--no-pager[Do not pipe output into a pager]' \
- {-h,--help}'[Show this help]' \
- '--version[Show package version]' \
- '*::systemd-coredumpctl commands:_systemd-coredumpctl_command'
More information about the systemd-commits
mailing list