From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19954 invoked from network); 19 Jul 2023 04:03:12 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Jul 2023 04:03:12 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1689739393; b=PQ1yDDJmuVSjz4lLLhmYyAEHmHW8ZqG2aO0eWLO2JO33/aOVXzjoFm+g9foZ3XoJ5VMX/u10Yc tgIA4kSDihpLgWvJV2NkxZRHHY64F8cOusSnwiEB0EeLES92FpVOSRPa9cUyYW4bvbK8aTX7GP YJz6l8+/V2P+4Ak+rTlV3seRTgbAs7dUxGVgDkI5QBannBwx9JG3EVKtynHthPcyPEZdL82GwP W3lANhIbhKclxG2B8V0dzN1gBZklrAKcrobjQmwlkzSEOlDKOQrlEq/yqLTOIUyYw9ihll3uz5 yEi4kxUyXWKIKYabJrm/Ha+cBJTG3/I9/mRjhGMp4NBlnQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pj1-f42.google.com) smtp.remote-ip=209.85.216.42; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1689739393; bh=5psgTWIhtbiAT3upmsYx7UT727cBhxTRTBFVQxxOuUs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:DKIM-Signature:DKIM-Signature; b=iwMzuXlCwLfCorbcIMDSGIJ4G9u9mfg98D+hWCWLANayHz53PaYyo3QlEG1B11lmo36WzANJHT gVxsQtoG5kiAEq/cPoljvTeJoepRfm93b0W881XMz4MTZ5yUdApaeG48akLRMGxv5PiIkD54vF TgL1YfUKV/lmqoN/FcXjRHEUsk9DIX/GYRNt3hznRzAQidU3kPrg9e52v2U8Q9Nc0SUKOCRqDw OMTvb5911dlsOUx30wNlRfrWPKI4lxuoTukUnQiXhoGuXdCRiI3Q50ZHH7BLMva8Zp9WIbg5lK w2ADY4rSFh5vSs0Sm03LRMkXJo40sxxPo9hMcHLrqdVMsg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=pBYuE9+zqwiOSdoebtRKZFUwI+vPkiXffT8ZcCtm7o4=; b=NZXm5mzu8DP+RoCPac3omkfnpV ZOofPX34AnAiBveXdDNL3UOJNhx3S9WGRG/jdeFw+zfmSbu5pmM35WIlrtHtbdckXGmQRKLxboZM9 TP83XAivK0JaKr1YSpLcCbpDbjyMUbr3tnzZWWk1SKUEqvHc8cEEgRAKG1ND5Fim0x9Ogha2VSf2R 3GMSE0zeP4beSCaGfnGG6BvybSEKC/3SB2sQ8bEpxpfd6zV5MnKTuTfSJvL+R9FhTTvukuwtZQnQJ 1uOwB8RDvbaR1VrGSgrJJ1yhppL9sqUmFJOyRxl3FGbIAQIldufyN6mHTFbYn4/gr369r1hVUf94d 2D5IZAGA==; Received: by zero.zsh.org with local id 1qLyP8-0000QO-Sp; Wed, 19 Jul 2023 04:03:10 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pj1-f42.google.com) smtp.remote-ip=209.85.216.42; dkim=pass header.d=gmail.com header.s=20221208 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pj1-f42.google.com ([209.85.216.42]:52257) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qLyJf-000Pxo-O5; Wed, 19 Jul 2023 03:57:34 +0000 Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-262f7b67da8so3549588a91.0 for ; Tue, 18 Jul 2023 20:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689739050; x=1690343850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pBYuE9+zqwiOSdoebtRKZFUwI+vPkiXffT8ZcCtm7o4=; b=K3IyAzIdpXMgdrJOuzdneI9TJXiY/TBqHh7osS2rhEyNlHzGOa40cBU4YzUZWWEBvU AOu6PoQKtT01CTK3MJa3Er1VoBxpG8QMOnsMKu+N4EG5GLliX2eOqfGXRPJwWkv3UBUE zNyjJrCUUeZUCaK4qMLmVCHMlkwvI4+5ssIL3ppeaeQeLkAwvZ7Hrv2RuDvMj5ZWXoWu TjnfjN09XJNxmSiP6EIx7AOZXxnkbv7xBEcbbPUjyTca+XRioWT7/PENofvuOowL3U2C e8K46mjqAgSue4sqpxm6M6voNySYparwRtFluRO2C5iqLPjnn/24A55EXBRGQ4SNjzKN Rqyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689739050; x=1690343850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pBYuE9+zqwiOSdoebtRKZFUwI+vPkiXffT8ZcCtm7o4=; b=Cs7Jfy5KpxD2b6jz5sE+cBzN9kf7j84Oq7KUB2vttbKxJkgxhNdAce8lOULkKRjiWF cP1sx83eFg049TiXJipzJ1UembViCKQ4ly0e2h52G94jokUq1TpcqPlgmLgkvlvF9HTr fSF7jfdOC/+FNUL1coXs6hYWYgArU6KFVjm02/zNuSggPX+zamGnsrnnyA5XS8p9gIrt D/Tt83lJt4yaV7+VpayBmquIwwnu7CFLzol/jCb8q4RN1v/Yc6foz0WGGvYI72DSLweF TMjxn/dQlghrLiyKSLa3d8gsWOsW+sBQBnbjpCtq5wEgC9fJ9gwQqb8T2zZwcpyDMGH/ rveQ== X-Gm-Message-State: ABy/qLaV14IxMU5v0COvoYU8VRDzFdx3jDkZSSywygoTikQyqNwsUsbb nSIJ+mm9j9usze/d6R2EW9fgggts5yg= X-Google-Smtp-Source: APBJJlFkWAEcWsbZIiiG+pqtuUYAiQc6I7ApitiNGCxHosOozZQIkYiPinb586i8QF1LIo0ufsMyGw== X-Received: by 2002:a17:90a:6548:b0:259:3e2a:b6d8 with SMTP id f8-20020a17090a654800b002593e2ab6d8mr14819630pjs.17.1689739050140; Tue, 18 Jul 2023 20:57:30 -0700 (PDT) Received: from localhost.localdomain (49.212.151.152.v6.sakura.ne.jp. [2403:3a00:202:1112:49:212:151:152]) by smtp.gmail.com with ESMTPSA id 26-20020a17090a1a1a00b00263987a50fcsm336853pjk.22.2023.07.18.20.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 20:57:29 -0700 (PDT) From: Shohei YOSHIDA To: zsh-workers@zsh.org Cc: Shohei YOSHIDA Subject: [PATCH] pidof: Support sysvinit-utils and Night Production versions Date: Wed, 19 Jul 2023 12:57:24 +0900 Message-Id: <20230719035724.93699-1-syohex@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 51964 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: The current pidof completion supports only procps version. However some Linux distributions like Ubuntu, Debian, use sysvinit-utils version by default. And they have diffrent CLI flags. And there is another pidof implementation on macOS. This patch supports those three versions. Reference - procps: https://man7.org/linux/man-pages/man1/pidof.1.html - sysvinit-utils: https://manpages.debian.org/testing/sysvinit-utils/pidof.8.en.html - nightmare-production: http://www.nightproductions.net/cli.htm --- Completion/Linux/Command/_pidof | 58 +++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/Completion/Linux/Command/_pidof b/Completion/Linux/Command/_pidof index dd0649ce9..151a0e0f6 100644 --- a/Completion/Linux/Command/_pidof +++ b/Completion/Linux/Command/_pidof @@ -3,19 +3,51 @@ local curcontext="$curcontext" state line expl ret=1 typeset -A opt_args -local exargs="-h --help -V --version" -_arguments -C -s -w \ - '(- *)'{-h,--help}'[display help information]' \ - '(- *)'{-V,--version}'[print program version]' \ - "(-s --single-shot $exargs)"{-s,--single-shot}'[return one PID only]' \ - "(-c --check-root $exargs)"{-c,--check-root}'[omit processes with different root]' \ - '-q[quiet mode, only set the exit code]' \ - '(-w --with-workers)'{-w,--with-workers}'[show kernel workers too]' \ - "(-x $exargs)"-x'[include shells running named scripts]' \ - "($exargs)"\*{-o+,--omit-pid=}'[omit processes with PIDs]:pids:_sequence -s , _pids' \ - '(-S --separator)'{-S+,--separator=}'[specify separator put between PIDs]:separator' \ - '*:process:->procnames' \ - && return 0 +_pick_variant -r variant procps='--separator' $OSTYPE -h + +case $variant in + (procps) + local exargs="-h --help -V --version" + _arguments -C -s -w \ + '(- *)'{-h,--help}'[display help information]' \ + '(- *)'{-V,--version}'[print program version]' \ + "(-s --single-shot $exargs)"{-s,--single-shot}'[return one PID only]' \ + "(-c --check-root $exargs)"{-c,--check-root}'[omit processes with different root]' \ + '-q[quiet mode, only set the exit code]' \ + '(-w --with-workers)'{-w,--with-workers}'[show kernel workers too]' \ + "(-x $exargs)"-x'[include shells running named scripts]' \ + "($exargs)"\*{-o+,--omit-pid=}'[omit processes with PIDs]:pids:_sequence -s , _pids' \ + '(-S --separator)'{-S+,--separator=}'[specify separator put between PIDs]:separator' \ + '*:process:->procnames' \ + && return 0 + ;; + (darwin*) + # Night Production pidof + _arguments -s -w \ + '(- *)'{-h,-\?}'[display help information]' \ + '(- *)-v[print out version info on pidof]' \ + '-l[print output in long format]' \ + '-k[kill processes by name]' \ + '*:process:_process_names -a' \ + && return 0 + ;; + (*) + # sysvinit-utils + _arguments -C -s -w \ + '(- *)-h[display help information]' \ + '-c[return PIDs with the same root directory]' \ + '-d[use the provided character as output separator]:separator' \ + '-n[avoid using stat system function on network shares]' \ + '-o[omit results with a given PID]:pid:_sequence -s , _pids' \ + '-s[return one PID only]' \ + '-q[quiet mode. Do not display output]' \ + '-s[only return one PID]' \ + '-x[return PIDs of shells running scripts with a matching name]' \ + '-z[list zombie and I/O waiting processes. May cause pidof to hang]' \ + '*:process:->procnames' \ + && return 0 + ;; +esac case $state in procnames) -- 2.39.2