1 # $FreeBSD: head/bin/sh/tests/expansion/trim2.0 206147 2010-04-03 21:07:50Z jilles $
3 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
16 if [ "x$result" = "x$expected" ]; then
20 echo "For $code, expected $expected actual $result"
25 testcase 'set -- $s' '1|ast*que?non'
26 testcase 'set -- ${s%\?*}' '1|ast*que'
27 testcase 'set -- "${s%\?*}"' '1|ast*que'
28 testcase 'set -- ${s%\**}' '1|ast'
29 testcase 'set -- "${s%\**}"' '1|ast'
30 testcase 'set -- ${s%"$q"*}' '1|ast*que'
31 testcase 'set -- "${s%"$q"*}"' '1|ast*que'
32 testcase 'set -- ${s%"$a"*}' '1|ast'
33 testcase 'set -- "${s%"$a"*}"' '1|ast'
34 testcase 'set -- ${s%"$q"$a}' '1|ast*que'
35 testcase 'set -- "${s%"$q"$a}"' '1|ast*que'
36 testcase 'set -- ${s%"$a"$a}' '1|ast'
37 testcase 'set -- "${s%"$a"$a}"' '1|ast'
40 testcase 'set -- "${b%\}}"' '1|{{(#)}'
41 # Parentheses are special in ksh, check that they can be escaped
42 testcase 'set -- "${b%\)*}"' '1|{{(#'
43 testcase 'set -- "${h#\#}"' '1|#'
45 testcase 'set -- ${p%"${p#?}"}' '1|/'
46 testcase 'set -- ${p%"${p#??????}"}' '1|/etc'
47 testcase 'set -- ${p%"${p#???????}"}' '1|/etc/'
48 testcase 'set -- "${p%"${p#?}"}"' '1|/'
49 testcase 'set -- "${p%"${p#??????}"}"' '1|/et[c]'
50 testcase 'set -- "${p%"${p#???????}"}"' '1|/et[c]/'
51 testcase 'set -- ${p#"${p}"}' '0|'
52 testcase 'set -- "${p#"${p}"}"' '1|'
53 testcase 'set -- "${p#*\[}"' '1|c]/'