mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2025-02-16 11:56:56 +00:00
base-files: functions.sh: Add prepend() homologue to append()
Sometimes it's useful to be able to prepend to a variable as well, such as when dealing with domain names, e.g. prepend fdqn "$subdomain" "." will result in: fqdn="$subdomain.$fqdn" Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
This commit is contained in:
parent
b23c2ec831
commit
1998027d7c
@ -40,6 +40,14 @@ append() {
|
||||
eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
|
||||
}
|
||||
|
||||
prepend() {
|
||||
local var="$1"
|
||||
local value="$2"
|
||||
local sep="${3:- }"
|
||||
|
||||
eval "export ${NO_EXPORT:+-n} -- \"$var=\${$value:+\${$value}\$sep}\$var\""
|
||||
}
|
||||
|
||||
list_contains() {
|
||||
local var="$1"
|
||||
local str="$2"
|
||||
|
Loading…
Reference in New Issue
Block a user