Skip to contentSkip to conversation

mdadm: Send version text to stdout rather than stderr

PATCH In review Zhilong Liu 3 participants 4 messages Jun 6, 2017 – Jun 7, 2017 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mdadm: Send version text to stdout rather than stderr

This helps with piping to a paper.

---
 mdadm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mdadm.c +1 -1
index 70b16f2..0f736d7 100644
@@ -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++;
Signature · 1 line
2.6.6
#1 lore raw
Quoted 1 line · Zhilong Liu

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

Quoted 26 lines
---
 mdadm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mdadm.c +1 -1
index 70b16f2..0f736d7 100644
@@ -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++;
Signature · 6 lines
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 11 lines · NeilBrown
Quoted 1 line · Zhilong Liu

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.

Quoted 6 lines

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

Quoted 27 lines

NeilBrtown

Quoted 25 lines
---
  mdadm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mdadm.c +1 -1
index 70b16f2..0f736d7 100644
@@ -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++;
Signature · 6 lines
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to NeilBrown
Quoted 12 lines · NeilBrown
Quoted 1 line · Zhilong Liu

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.

Quoted 8 lines

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