From: Richard Retanubun <richardretanubun@ruggedcom.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "dash@vger.kernel.org" <dash@vger.kernel.org>
Subject: Re: /bin/dash -c != /bin/bash -c with pgrep
Date: Tue, 24 Jan 2012 15:17:12 -0500 [thread overview]
Message-ID: <4F1F11C8.9000200@ruggedcom.com> (raw)
In-Reply-To: <20120124194342.GC2956@burratino>
On 24/01/12 02:43 PM, Jonathan Nieder wrote:
> Hi Richard,
>
> Richard Retanubun wrote:
>
>> /bin/dash -c "pgrep -f /usr/sbin/atftpd"; echo $?
>> -vs-
>> /bin/bash -c "pgrep -f /usr/sbin/atftpd"; echo $?
>>
>> The dash version returns the PID of the grep itself and thus always succeeds.
>> The bash version works as expected.
>
> As the pgrep(1) manual explains, the running pgrep or pkill process
> will never report itself as a match. However, when running pgrep
> through dash, it reports the process id of the shell executing pgrep,
> while the bash version and recent dash versions optimize "sh -c
> 'single command'" to
>
> sh -c 'exec pgrep -f /usr/sbin/atftpd'
>
> so there is no shell process left to report.
>
> If that "exec" is specified explicitly, the result is the same in both
> shells.
>
> Hope that helps,
> Jonathan
It sure does, thanks a lot Jonathan.
As an addendum, I find using "pgrep -x atftpd" in this case also yields the
expected output in both shell.
Thanks for your time.
-- RR --
next prev parent reply other threads:[~2012-01-24 20:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-24 15:51 /bin/dash -c != /bin/bash -c with pgrep Richard Retanubun
2012-01-24 19:43 ` Jonathan Nieder
2012-01-24 20:17 ` Richard Retanubun [this message]
2012-01-24 20:53 ` Richard Retanubun
2012-01-24 21:03 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F1F11C8.9000200@ruggedcom.com \
--to=richardretanubun@ruggedcom.com \
--cc=dash@vger.kernel.org \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox