trim3.0 revision 207127
160107Sobrien# $FreeBSD: head/tools/regression/bin/sh/expansion/trim3.0 207127 2010-04-23 17:26:49Z jilles $ 24564Sache 34564Sachee= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' 44564Sacheh='##' c='\\\\' 54564Sachefailures='' 64564Sacheok='' 74564Sache 84564Sachetestcase() { 94564Sache code="$1" 104564Sache expected="$2" 114564Sache oIFS="$IFS" 124564Sache eval "$code" 134564Sache IFS='|' 144564Sache result="$#|$*" 154564Sache IFS="$oIFS" 164564Sache if [ "x$result" = "x$expected" ]; then 174564Sache ok=x$ok 1838140Syokota else 194564Sache failures=x$failures 206867Sache echo "For $code, expected $expected actual $result" 214686Sache fi 224564Sache} 234564Sache 244564Sache# This doesn't make much sense, but it fails in dash so I'm adding it here: 254564Sachetestcase 'set -- "${w%${w#???}}"' '1|a b' 264564Sache 274564Sachetestcase 'set -- ${p#/et[}' '1|c]/' 284564Sachetestcase 'set -- "${p#/et[}"' '1|c]/' 294564Sachetestcase 'set -- "${p%${p#????}}"' '1|/et[' 304564Sache 314564Sachetestcase 'set -- ${b%'\'}\''}' '1|{{(#)}' 324564Sache 334564Sachetestcase 'set -- ${c#\\}' '1|\\\' 344564Sachetestcase 'set -- ${c#\\\\}' '1|\\' 354564Sachetestcase 'set -- ${c#\\\\\\}' '1|\' 364564Sachetestcase 'set -- ${c#\\\\\\\\}' '0|' 374564Sachetestcase 'set -- "${c#\\}"' '1|\\\' 384564Sachetestcase 'set -- "${c#\\\\}"' '1|\\' 394564Sachetestcase 'set -- "${c#\\\\\\}"' '1|\' 404564Sachetestcase 'set -- "${c#\\\\\\\\}"' '1|' 414564Sachetestcase 'set -- "${c#"$c"}"' '1|' 424564Sachetestcase 'set -- ${c#"$c"}' '0|' 434564Sachetestcase 'set -- "${c%"$c"}"' '1|' 444564Sachetestcase 'set -- ${c%"$c"}' '0|' 454564Sache 464564Sachetest "x$failures" = x 474564Sache