summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-11-24 21:04:56 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-11-24 21:04:56 -0500
commite2ee1a956a3b11d1840fc051443923b54339072b (patch)
tree5bdccd9a43253e799448618556243d3788bb7729
parent6b820421d9ffe0599d9ff3f20703b2e2a04e4af8 (diff)
downloadbfs-e2ee1a956a3b11d1840fc051443923b54339072b.tar.xz
Allow // to be different from /
POSIX says that // may be resolved in an implementation-defined way (generally, to access network shares). So don't use it in tests, and don't canonicalize it to '/' in -execdir.
-rw-r--r--eval.c9
-rwxr-xr-xtests.sh5
-rw-r--r--tests/test_0044.out2
-rw-r--r--tests/test_0100.out2
4 files changed, 8 insertions, 10 deletions
diff --git a/eval.c b/eval.c
index 575eebd..d3b8f19 100644
--- a/eval.c
+++ b/eval.c
@@ -261,8 +261,6 @@ bool eval_delete(const struct expr *expr, struct eval_state *state) {
return true;
}
-static const char *exec_slash = "/";
-
static const char *exec_format_path(const struct expr *expr, const struct BFTW *ftwbuf) {
if (!(expr->exec_flags & EXEC_CHDIR)) {
return ftwbuf->path;
@@ -271,8 +269,9 @@ static const char *exec_format_path(const struct expr *expr, const struct BFTW *
const char *name = ftwbuf->path + ftwbuf->nameoff;
if (name[0] == '/') {
- // Must be the root path ("/", "//", etc.), which we canonicalize
- return exec_slash;
+ // Must be a root path ("/", "//", etc.)
+ assert(ftwbuf->nameoff == 0);
+ return name;
}
// For compatibility with GNU find, use './name' instead of just 'name'
@@ -299,7 +298,7 @@ err:
}
static void exec_free_path(const char *path, const struct BFTW *ftwbuf) {
- if (path != ftwbuf->path && path != exec_slash) {
+ if (path != ftwbuf->path) {
dstrfree((char *)path);
}
}
diff --git a/tests.sh b/tests.sh
index 08410d2..54371fd 100755
--- a/tests.sh
+++ b/tests.sh
@@ -289,7 +289,7 @@ function test_0043() {
}
function test_0044() {
- bfs_diff // -maxdepth 0 -name / 2>/dev/null
+ bfs_diff /// -maxdepth 0 -name / 2>/dev/null
}
function test_0045() {
@@ -536,8 +536,7 @@ function test_0099() {
}
function test_0100() {
- # // is canonicalized to /
- bfs_diff // -maxdepth 0 -execdir echo '{}' ';'
+ bfs_diff /// -maxdepth 0 -execdir echo '{}' ';'
}
for i in {1..100}; do
diff --git a/tests/test_0044.out b/tests/test_0044.out
index 8337712..187b81f 100644
--- a/tests/test_0044.out
+++ b/tests/test_0044.out
@@ -1 +1 @@
-//
+///
diff --git a/tests/test_0100.out b/tests/test_0100.out
index b498fd4..187b81f 100644
--- a/tests/test_0100.out
+++ b/tests/test_0100.out
@@ -1 +1 @@
-/
+///