Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH] mdadm: Send version text to stdout rather than stderr
@ 2017-06-06  7:59 Zhilong Liu
  2017-06-07  1:44 ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: Zhilong Liu @ 2017-06-06  7:59 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, Zhilong Liu

This helps with piping to a paper.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
---
 mdadm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mdadm.c b/mdadm.c
index 70b16f2..0f736d7 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
 			continue;
 
 		case 'V':
-			fputs(Version, stderr);
+			fputs(Version, stdout);
 			exit(0);
 
 		case 'v': c.verbose++;
-- 
2.6.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Send version text to stdout rather than stderr
  2017-06-06  7:59 [PATCH] mdadm: Send version text to stdout rather than stderr Zhilong Liu
@ 2017-06-07  1:44 ` NeilBrown
  2017-06-07  2:11   ` Zhilong Liu
  2017-06-07 15:21   ` Jes Sorensen
  0 siblings, 2 replies; 4+ messages in thread
From: NeilBrown @ 2017-06-07  1:44 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, Zhilong Liu

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

On Tue, Jun 06 2017, Zhilong Liu wrote:

> This helps with piping to a paper.

It might help you, but it is an API change and could cause problems for
others.

Some programs, such as "mount -V", send version info to stdout.
Others, like "gcc -v", send it to stderr.
There is no uniform standard, it is best to leave the behavior
unchanged.

If you need to capture the output use
   mdadm -V |& ...
or
   mdadm -V 2>&1

or similar.

NeilBrtown

>
> Signed-off-by: Zhilong Liu <zlliu@suse.com>
> ---
>  mdadm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mdadm.c b/mdadm.c
> index 70b16f2..0f736d7 100644
> --- a/mdadm.c
> +++ b/mdadm.c
> @@ -139,7 +139,7 @@ int main(int argc, char *argv[])
>  			continue;
>  
>  		case 'V':
> -			fputs(Version, stderr);
> +			fputs(Version, stdout);
>  			exit(0);
>  
>  		case 'v': c.verbose++;
> -- 
> 2.6.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Send version text to stdout rather than stderr
  2017-06-07  1:44 ` NeilBrown
@ 2017-06-07  2:11   ` Zhilong Liu
  2017-06-07 15:21   ` Jes Sorensen
  1 sibling, 0 replies; 4+ messages in thread
From: Zhilong Liu @ 2017-06-07  2:11 UTC (permalink / raw)
  To: NeilBrown, Jes.Sorensen; +Cc: linux-raid



On 06/07/2017 09:44 AM, NeilBrown wrote:
> On Tue, Jun 06 2017, Zhilong Liu wrote:
>
>> This helps with piping to a paper.
> It might help you, but it is an API change and could cause problems for
> others.
>
> Some programs, such as "mount -V", send version info to stdout.
> Others, like "gcc -v", send it to stderr.
> There is no uniform standard, it is best to leave the behavior
> unchanged.
>
> If you need to capture the output use
>     mdadm -V |& ...
> or
>     mdadm -V 2>&1
>
> or similar.

Thanks for your detail explanations. Yes, I just encountered this issue 
in my progress of improving ./mdadm/test script,
the ./mdadm --version always prints to stderr, thus I post this email, 
and I have already used "2>&1" in my test script.

Thanks very much,
-Zhilong

> NeilBrtown
>
>> Signed-off-by: Zhilong Liu <zlliu@suse.com>
>> ---
>>   mdadm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mdadm.c b/mdadm.c
>> index 70b16f2..0f736d7 100644
>> --- a/mdadm.c
>> +++ b/mdadm.c
>> @@ -139,7 +139,7 @@ int main(int argc, char *argv[])
>>   			continue;
>>   
>>   		case 'V':
>> -			fputs(Version, stderr);
>> +			fputs(Version, stdout);
>>   			exit(0);
>>   
>>   		case 'v': c.verbose++;
>> -- 
>> 2.6.6
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mdadm: Send version text to stdout rather than stderr
  2017-06-07  1:44 ` NeilBrown
  2017-06-07  2:11   ` Zhilong Liu
@ 2017-06-07 15:21   ` Jes Sorensen
  1 sibling, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2017-06-07 15:21 UTC (permalink / raw)
  To: NeilBrown, Zhilong Liu; +Cc: linux-raid

On 06/06/2017 09:44 PM, NeilBrown wrote:
> On Tue, Jun 06 2017, Zhilong Liu wrote:
> 
>> This helps with piping to a paper.
> 
> It might help you, but it is an API change and could cause problems for
> others.
> 
> Some programs, such as "mount -V", send version info to stdout.
> Others, like "gcc -v", send it to stderr.
> There is no uniform standard, it is best to leave the behavior
> unchanged.
> 
> If you need to capture the output use
>     mdadm -V |& ...
> or
>     mdadm -V 2>&1
> 
> or similar.
> 
> NeilBrtown

I agree with mr Brtown here :)

Changing the API is a big issue. We need to avoid this unless it is 
absolutely necessary, so we don't break things for people trying to run 
newer mdadm on older distros or those relying on third party scripts.

Jes

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-07 15:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-06  7:59 [PATCH] mdadm: Send version text to stdout rather than stderr Zhilong Liu
2017-06-07  1:44 ` NeilBrown
2017-06-07  2:11   ` Zhilong Liu
2017-06-07 15:21   ` Jes Sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox