sh: Add some tests for ${#parameter}.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sat, 16 Apr 2011 21:40:50 +0000 (11:40 -1000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sat, 16 Apr 2011 21:55:51 +0000 (11:55 -1000)
Obtained-from: FreeBSD

tools/regression/bin/sh/expansion/length1.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/length2.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/length3.0 [new file with mode: 0644]

diff --git a/tools/regression/bin/sh/expansion/length1.0 b/tools/regression/bin/sh/expansion/length1.0
new file mode 100644 (file)
index 0000000..199e280
--- /dev/null
@@ -0,0 +1,12 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/length1.0,v 1.1 2011/03/13 16:20:38 jilles Exp $
+
+v=abcd
+[ "${#v}" = 4 ] || echo '${#v} wrong'
+v=$$
+[ "${#$}" = "${#v}" ] || echo '${#$} wrong'
+[ "${#!}" = 0 ] || echo '${#!} wrong'
+set -- 01 2 3 4 5 6 7 8 9 10 11 12 0013
+[ "${#1}" = 2 ] || echo '${#1} wrong'
+[ "${#13}" = 4 ] || echo '${#13} wrong'
+v=$0
+[ "${#0}" = "${#v}" ] || echo '${#0} wrong'
diff --git a/tools/regression/bin/sh/expansion/length2.0 b/tools/regression/bin/sh/expansion/length2.0
new file mode 100644 (file)
index 0000000..78e9f53
--- /dev/null
@@ -0,0 +1,4 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/length2.0,v 1.1 2011/03/13 16:20:38 jilles Exp $
+
+v=$-
+[ "${#-}" = "${#v}" ] || echo '${#-} wrong'
diff --git a/tools/regression/bin/sh/expansion/length3.0 b/tools/regression/bin/sh/expansion/length3.0
new file mode 100644 (file)
index 0000000..015462c
--- /dev/null
@@ -0,0 +1,10 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/length3.0,v 1.1 2011/03/13 16:20:38 jilles Exp $
+
+set -- 1 2 3 4 5 6 7 8 9 10 11 12 13
+[ "$#" = 13 ] || echo '$# wrong'
+[ "${#}" = 13 ] || echo '${#} wrong'
+[ "${##}" = 2 ] || echo '${##} wrong'
+set --
+[ "$#" = 0 ] || echo '$# wrong'
+[ "${#}" = 0 ] || echo '${#} wrong'
+[ "${##}" = 1 ] || echo '${##} wrong'