zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] print errors to stderr
@ 2016-06-22  6:53 isabella parakiss
  2016-06-22  7:42 ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: isabella parakiss @ 2016-06-22  6:53 UTC (permalink / raw)
  To: zsh-workers

From 6fa7a56ee8cab083f4d9f4f13a2e1a11ff72bdef Mon Sep 17 00:00:00 2001
From: izabera <izaberina@gmail.com>
Date: Wed, 22 Jun 2016 08:44:57 +0200
Subject: [PATCH] print errors to stderr

---
 Src/builtin.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index c2fb81e..891e203 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3633,8 +3633,8 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 		}
 	    }
 	    if (!informed && (wd || v || csh)) {
-		zputs(*argv, stdout);
-		puts(wd ? ": none" : " not found");
+		zputs(*argv, stderr);
+		zputs(wd ? ": none" : " not found", stderr);
 		returnval = 1;
 	    }
 	    popheap();
@@ -3654,7 +3654,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 	} else {
 	    /* Not found at all. */
 	    if (v || csh || wd)
-		zputs(*argv, stdout), puts(wd ? ": none" : " not found");
+		zputs(*argv, stderr), zputs(wd ? ": none" : " not found", stderr);
 	    returnval = 1;
 	}
     }
-- 
2.9.0


---
xoxo iza


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

* Re: [PATCH] print errors to stderr
  2016-06-22  6:53 [PATCH] print errors to stderr isabella parakiss
@ 2016-06-22  7:42 ` Oliver Kiddle
  2016-06-22 17:14   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2016-06-22  7:42 UTC (permalink / raw)
  To: isabella parakiss; +Cc: zsh-workers

isabella parakiss wrote:
> Subject: [PATCH] print errors to stderr
> @@ -3633,8 +3633,8 @@ bin_whence(char *nam, char **argv, Options ops, int func)
> -		zputs(*argv, stdout);
> -		puts(wd ? ": none" : " not found");
> +		zputs(*argv, stderr);
> +		zputs(wd ? ": none" : " not found", stderr);

I think this behaviour is actually intentional. It is arguably not an
error - the whence command's purpose is to search for something and
report on whether it is found. So it doesn't rely on finding it. Also,
this is compatible with csh and tcsh - the which command was a csh thing
first.

Oliver


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

* Re: [PATCH] print errors to stderr
  2016-06-22  7:42 ` Oliver Kiddle
@ 2016-06-22 17:14   ` Bart Schaefer
  2016-06-23 10:04     ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2016-06-22 17:14 UTC (permalink / raw)
  To: zsh-workers

On Jun 22,  9:42am, Oliver Kiddle wrote:
} 
} I think this behaviour is actually intentional. It is arguably not an
} error - the whence command's purpose is to search for something and
} report on whether it is found. So it doesn't rely on finding it. Also,
} this is compatible with csh and tcsh - the which command was a csh thing
} first.

Maybe it's time for either the doc or a code comment to explain this,
because I recall having this same discussion with someone else several
months ago.


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

* Re: [PATCH] print errors to stderr
  2016-06-22 17:14   ` Bart Schaefer
@ 2016-06-23 10:04     ` Oliver Kiddle
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Kiddle @ 2016-06-23 10:04 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:
> } I think this behaviour is actually intentional. It is arguably not an
> } error - the whence command's purpose is to search for something and
> } report on whether it is found. So it doesn't rely on finding it. Also,
> } this is compatible with csh and tcsh - the which command was a csh thing
> } first.
>
> Maybe it's time for either the doc or a code comment to explain this,

Sounds sensible.

Oliver

diff --git a/Src/builtin.c b/Src/builtin.c
index c2fb81e..bfb9e69 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3633,6 +3633,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 		}
 	    }
 	    if (!informed && (wd || v || csh)) {
+		/* this is information and not an error so, as in csh, use stdout */
 		zputs(*argv, stdout);
 		puts(wd ? ": none" : " not found");
 		returnval = 1;
@@ -3652,7 +3653,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 	    }
 	    informed = 1;
 	} else {
-	    /* Not found at all. */
+	    /* Not found at all. That's not an error as such so this goes to stdout */
 	    if (v || csh || wd)
 		zputs(*argv, stdout), puts(wd ? ": none" : " not found");
 	    returnval = 1;


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

end of thread, other threads:[~2016-06-23 10:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22  6:53 [PATCH] print errors to stderr isabella parakiss
2016-06-22  7:42 ` Oliver Kiddle
2016-06-22 17:14   ` Bart Schaefer
2016-06-23 10:04     ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).