From c6599399ec36c941bbd2c504f1aebf2b45816ace Mon Sep 17 00:00:00 2001
From: Bernd Jendrissek <bernd.jendrissek@gmail.com>
Date: Thu, 21 Jun 2012 01:04:28 +0200
Subject: [PATCH] Do use readlink if available

The main effect of this patch is to make gnulib-tool not spam the
terminal with failures from ls. Despite the copious stderr output,
files still get linked correctly.

	gnulib-tool: Use readlink if it is available.
	* gnulib-tool (func_readlink): Choose function more appropriately.

Running under dash, type -p readlink fails because dash doesn't
understand -p. That causes gnulib-tool to fall back to ls to read
symlinks, despite readlink being available. That, in turn, spams the
terminal when func_ln_if_changed's DEST argument doesn't exist.

The output from type goes to /dev/null anyway, so asking for -p has no
purpose.
---
 ChangeLog   | 5 +++++
 gnulib-tool | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b3110ba61c..442c4ec652 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-20  Bernd Jendrissek  <bernd.jendrissek@gmail.com>  (tiny change)
+
+	gnulib-tool: Use readlink if it is available.
+	* gnulib-tool (func_readlink): Choose function more appropriately.
+
 2012-06-21  Paul Eggert  <eggert@cs.ucla.edu>
 
 	posixtm-tests: port to buggy compiler
diff --git a/gnulib-tool b/gnulib-tool
index 16f9b2f7f3..6213f50e81 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -591,7 +591,7 @@ func_warning ()
 
 # func_readlink SYMLINK
 # outputs the target of the given symlink.
-if (type -p readlink) > /dev/null 2>&1; then
+if (type readlink) > /dev/null 2>&1; then
   func_readlink ()
   {
     # Use the readlink program from GNU coreutils.
-- 
2.39.5