mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 01:41:52 -05:00
pacman-key: simplify writing to config file
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
dd82b8d09f
commit
b6ccae2d18
@ -131,13 +131,11 @@ secret_keys_available() {
|
||||
# Note that if we find it commented out, we won't add the option.
|
||||
# args: $1 conffile, $2 option-name, $3 (optional) option-value
|
||||
add_gpg_conf_option() {
|
||||
local confline
|
||||
local conffile=$1; shift
|
||||
# looking for the option 'bare', only leading spaces or # chars allowed,
|
||||
# followed by at least one space and any other text or the end of line.
|
||||
if ! grep -q "^[[:space:]#]*$2\([[:space:]].*\)*$" "$1" &>/dev/null; then
|
||||
confline="$2"
|
||||
[[ -n $3 ]] && confline="$2 $3"
|
||||
echo "$confline" >> "$1"
|
||||
if ! grep -q "^[[:space:]#]*$1\([[:space:]].*\)*$" "$conffile" &>/dev/null; then
|
||||
printf '%s\n' "$*" >> "$conffile"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user