15
lib/runtime/merge/keyValue/key-value.sh
Normal file
15
lib/runtime/merge/keyValue/key-value.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
source=$(realpath -m "$1")
|
||||
target=$(realpath -m "$2")
|
||||
|
||||
if [[ -f "$target" ]]; then
|
||||
temp=$(mktemp)
|
||||
awk -F '=' 'NR==FNR{a[$1]=$0;next}($1 in a){$0=a[$1]}1' "$source" "$target" > "$temp"
|
||||
mv "$temp" "$target"
|
||||
else
|
||||
mkdir -p "$(dirname "$target")"
|
||||
cp "$source" "$target"
|
||||
fi
|
||||
|
||||
echo "Configuration file $target has been updated."
|
Reference in New Issue
Block a user