Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sh: Add simple CDPATH test.

Obtained-from:  FreeBSD 222379
  • Loading branch information...
commit 690a7448b8b79bdbea6ae6b108ed5380a8548ccc 1 parent 1453408
Peter Avalos authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 tools/regression/bin/sh/builtins/cd5.0
View
23 tools/regression/bin/sh/builtins/cd5.0
@@ -0,0 +1,23 @@
+# $FreeBSD: src/tools/regression/bin/sh/builtins/cd5.0,v 1.1 2011/05/27 19:36:07 jilles Exp $
+
+set -e
+T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX")
+trap 'rm -rf "$T"' 0
+
+cd -P "$T"
+D=$(pwd)
+
+mkdir a a/1 b b/1 b/2
+
+CDPATH=$D/a:
+# Basic test.
+cd 1 >/dev/null
+[ "$(pwd)" = "$D/a/1" ]
+# Test that the current directory is not checked before CDPATH.
+cd "$D/b"
+cd 1 >/dev/null
+[ "$(pwd)" = "$D/a/1" ]
+# Test not using a CDPATH entry.
+cd "$D/b"
+cd 2
+[ "$(pwd)" = "$D/b/2" ]
Please sign in to comment.
Something went wrong with that request. Please try again.