Project

General

Profile

« Previous | Next » 

Revision 9711

lib/sh/util.sh: added match_prefix()

View differences:

lib/sh/util.sh
181 181

  
182 182
starts_with() { test "${2#$1}" != "$2"; } # usage: starts_with pattern str
183 183

  
184
match_prefix() # usage: match_prefix pattern str
185
{ if starts_with "$1" "$2"; then echo "${2%${2#$1}}"; fi }
186

  
184 187
repeat() # usage: str=... n=... repeat
185 188
{
186 189
	: "${str?}" "${n:?}"; local result= n="$n" # n will be modified in function

Also available in: Unified diff