git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Git Mailing List <git@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] guilt: fix portability problem with using find -perm +111
Date: Sat,  9 Jul 2016 18:18:35 -0400	[thread overview]
Message-ID: <1468102715-465-1-git-send-email-tytso@mit.edu> (raw)

GNU find no longers accepts -perm +111, even though the rest of the
world (MacOS, Solaris, BSD) still do.  Workaround this problem by
using -executable if the system find utility will accept it.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 guilt | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guilt b/guilt
index 38d426b..b90f02d 100755
--- a/guilt
+++ b/guilt
@@ -73,8 +73,17 @@ GUILT_PATH="$(dirname "$0")"
 
 guilt_commands()
 {
-	find "$GUILT_PATH/../lib/guilt" -maxdepth 1 -name "guilt-*" -type f -perm +111 2> /dev/null | sed -e "s/.*\\/$GUILT-//"
-	find "$GUILT_PATH" -maxdepth 1 -name "guilt-*" -type f -perm +111 | sed -e "s/.*\\/$GUILT-//"
+	# GNU Find no longer accepts -perm +111, even though the rest
+	# world (MacOS, Solaris, BSD, etc.) does.  Sigh.  Using -executable
+	# is arugably better, but it is a GNU extension.  Since this isn't
+	# a fast path and guilt doesn't use autoconf, test for it as needed.
+	if find . -maxdepth 0 -executable > /dev/null 2>&1 ; then
+		exe_test="-executable"
+	else
+		exe_test="-find +111"
+	fi
+	find "$GUILT_PATH/../lib/guilt" -maxdepth 1 -name "guilt-*" -type f $exe_test 2> /dev/null | sed -e "s/.*\\/$GUILT-//"
+	find "$GUILT_PATH" -maxdepth 1 -name "guilt-*" -type f $exe_test | sed -e "s/.*\\/$GUILT-//"
 }
 
 # by default, we shouldn't fail
-- 
2.5.0


             reply	other threads:[~2016-07-09 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-09 22:18 Theodore Ts'o [this message]
2016-07-10  7:01 ` [PATCH] guilt: fix portability problem with using find -perm +111 Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468102715-465-1-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).