diff options
author | jilles <jilles@FreeBSD.org> | 2011-03-13 20:02:39 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-03-13 20:02:39 +0000 |
commit | 161663c247c528c78fb3d3ec62b4d826259dd707 (patch) | |
tree | f8703bdb3bbcc10652390ec6b284f73b32c8f503 /tools | |
parent | eed23027f077c062772ce762806a18153a55cb4b (diff) | |
download | FreeBSD-src-161663c247c528c78fb3d3ec62b4d826259dd707.zip FreeBSD-src-161663c247c528c78fb3d3ec62b4d826259dd707.tar.gz |
sh: Fix some parameter expansion variants ${#...}.
These already worked: $# ${#} ${##} ${#-} ${#?}
These now work as well: ${#+word} ${#-word} ${##word} ${#%word}
There is an ambiguity in the standard with ${#?}: it could be the length of
$? or it could be $# giving an error in the (impossible) case that it is not
set. We continue to use the former interpretation as it seems more useful.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/expansion/plus-minus8.0 | 5 | ||||
-rw-r--r-- | tools/regression/bin/sh/expansion/trim7.0 | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/plus-minus8.0 b/tools/regression/bin/sh/expansion/plus-minus8.0 new file mode 100644 index 0000000..beba009 --- /dev/null +++ b/tools/regression/bin/sh/expansion/plus-minus8.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +set -- 1 2 3 4 5 6 7 8 9 10 11 12 13 +[ "${#+hi}" = hi ] || echo '${#+hi} wrong' +[ "${#-hi}" = 13 ] || echo '${#-hi} wrong' diff --git a/tools/regression/bin/sh/expansion/trim7.0 b/tools/regression/bin/sh/expansion/trim7.0 new file mode 100644 index 0000000..352bdea --- /dev/null +++ b/tools/regression/bin/sh/expansion/trim7.0 @@ -0,0 +1,16 @@ +# $FreeBSD$ + +set -- 1 2 3 4 5 6 7 8 9 10 11 12 13 +[ "${##1}" = 3 ] || echo '${##1} wrong' +[ "${###1}" = 3 ] || echo '${###1} wrong' +[ "${###}" = 13 ] || echo '${###} wrong' +[ "${#%3}" = 1 ] || echo '${#%3} wrong' +[ "${#%%3}" = 1 ] || echo '${#%%3} wrong' +[ "${#%%}" = 13 ] || echo '${#%%} wrong' +set -- +[ "${##0}" = "" ] || echo '${##0} wrong' +[ "${###0}" = "" ] || echo '${###0} wrong' +[ "${###}" = 0 ] || echo '${###} wrong' +[ "${#%0}" = "" ] || echo '${#%0} wrong' +[ "${#%%0}" = "" ] || echo '${#%%0} wrong' +[ "${#%%}" = 0 ] || echo '${#%%} wrong' |