Introduce xfeed output function
This commit is contained in:
parent
5122bf09cb
commit
67697c2b32
1 changed files with 17 additions and 13 deletions
|
@ -35,12 +35,16 @@ Repack_limit=25
|
||||||
Recipients=
|
Recipients=
|
||||||
|
|
||||||
# compat/utility functions
|
# compat/utility functions
|
||||||
xecho()
|
# xfeed: The most basic output function puts $1 into the stdin of $2..$#
|
||||||
|
xfeed()
|
||||||
{
|
{
|
||||||
cat <<EOF
|
local input_=
|
||||||
$@
|
input_=$1; shift
|
||||||
|
"$@" <<EOF
|
||||||
|
$input_
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
xecho() { xfeed "$*" cat; }
|
||||||
xecho_n() { xecho "$@" | tr -d \\n ; } # kill newlines
|
xecho_n() { xecho "$@" | tr -d \\n ; } # kill newlines
|
||||||
echo_git() { xecho "$@" ; } # Code clarity
|
echo_git() { xecho "$@" ; } # Code clarity
|
||||||
echo_info() { xecho "gcrypt:" "$@" >&2; }
|
echo_info() { xecho "gcrypt:" "$@" >&2; }
|
||||||
|
@ -267,7 +271,7 @@ REMOVE()
|
||||||
echo_info "sftp: Ignore remove request $1/$2"
|
echo_info "sftp: Ignore remove request $1/$2"
|
||||||
elif isurl rsync "$1"
|
elif isurl rsync "$1"
|
||||||
then
|
then
|
||||||
xecho "$2" | rsync -I -W -v -r --delete --include-from=- \
|
xfeed "$2" rsync -I -W -v -r --delete --include-from=- \
|
||||||
--exclude='*' "$Localdir"/ "${1#rsync://}/" >&2
|
--exclude='*' "$Localdir"/ "${1#rsync://}/" >&2
|
||||||
elif islocalrepo "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
|
@ -322,8 +326,8 @@ PRIVDECRYPT()
|
||||||
local status_=
|
local status_=
|
||||||
exec 4>&1 &&
|
exec 4>&1 &&
|
||||||
status_=$(gpg --status-fd 3 -q -d 3>&1 1>&4) &&
|
status_=$(gpg --status-fd 3 -q -d 3>&1 1>&4) &&
|
||||||
xecho "$status_" | grep "^\[GNUPG:\] ENC_TO " >/dev/null &&
|
xfeed "$status_" grep "^\[GNUPG:\] ENC_TO " >/dev/null &&
|
||||||
(xecho "$status_" | grep -e "$1" >/dev/null || {
|
(xfeed "$status_" grep -e "$1" >/dev/null || {
|
||||||
echo_info "Failed to verify manifest signature!" &&
|
echo_info "Failed to verify manifest signature!" &&
|
||||||
echo_info "Only accepting signatories: ${2:-(none)}" &&
|
echo_info "Only accepting signatories: ${2:-(none)}" &&
|
||||||
return 1
|
return 1
|
||||||
|
@ -406,7 +410,7 @@ read_config()
|
||||||
isnull "$r_keyinfo" || isnonnull "${r_keyinfo##*"$Newline"*}" ||
|
isnull "$r_keyinfo" || isnonnull "${r_keyinfo##*"$Newline"*}" ||
|
||||||
echo_info "WARNING: '$recp_' matches multiple keys, using one"
|
echo_info "WARNING: '$recp_' matches multiple keys, using one"
|
||||||
r_keyinfo=${r_keyinfo%%"$Newline"*}
|
r_keyinfo=${r_keyinfo%%"$Newline"*}
|
||||||
keyid_=$(xecho "$r_keyinfo" | cut -f 5 -d :)
|
keyid_=$(xfeed "$r_keyinfo" cut -f 5 -d :)
|
||||||
|
|
||||||
isnonnull "$keyid_" &&
|
isnonnull "$keyid_" &&
|
||||||
signers_="$signers_ $keyid_" &&
|
signers_="$signers_ $keyid_" &&
|
||||||
|
@ -415,7 +419,7 @@ read_config()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
# Check 'E'ncrypt capability
|
# Check 'E'ncrypt capability
|
||||||
cap_=$(xecho "$r_keyinfo" | cut -f 12 -d :)
|
cap_=$(xfeed "$r_keyinfo" cut -f 12 -d :)
|
||||||
iseq "${cap_#*E}" "$cap_" || Recipients="$Recipients -R $keyid_"
|
iseq "${cap_#*E}" "$cap_" || Recipients="$Recipients -R $keyid_"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -619,7 +623,7 @@ $Keeplist
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xecho "$r_del_list" | get_pack_files "$Localdir/pack/"
|
xfeed "$r_del_list" get_pack_files "$Localdir/pack/"
|
||||||
|
|
||||||
(set +f; git verify-pack -v "$Localdir"/pack/*.idx ||
|
(set +f; git verify-pack -v "$Localdir"/pack/*.idx ||
|
||||||
echo_kill "git verify-pack failed!") |
|
echo_kill "git verify-pack failed!") |
|
||||||
|
@ -668,12 +672,12 @@ do_fetch()
|
||||||
pick_fields_1_2 @premote_ "$Packlist"
|
pick_fields_1_2 @premote_ "$Packlist"
|
||||||
if [ -s "$Localdir/have_packs+" ]
|
if [ -s "$Localdir/have_packs+" ]
|
||||||
then
|
then
|
||||||
pneed_=$(xecho "$premote_" | xgrep -v -x -f "$Localdir/have_packs+")
|
pneed_=$(xfeed "$premote_" xgrep -v -x -f "$Localdir/have_packs+")
|
||||||
else
|
else
|
||||||
pneed_=$premote_
|
pneed_=$premote_
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xecho "$pneed_" | get_pack_files
|
xfeed "$pneed_" get_pack_files
|
||||||
|
|
||||||
echo_git # end with blank line
|
echo_git # end with blank line
|
||||||
}
|
}
|
||||||
|
@ -698,7 +702,7 @@ do_push()
|
||||||
if isnonnull "$Refslist"
|
if isnonnull "$Refslist"
|
||||||
then
|
then
|
||||||
# mark all remote refs with ^<sha-1> (if sha-1 exists locally)
|
# mark all remote refs with ^<sha-1> (if sha-1 exists locally)
|
||||||
r_revlist=$(xecho "$Refslist" | cut -f 1 -d ' ' |
|
r_revlist=$(xfeed "$Refslist" cut -f 1 -d ' ' |
|
||||||
safe_git_rev_parse | sed -e 's/^\(.\)/^&/')
|
safe_git_rev_parse | sed -e 's/^\(.\)/^&/')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -710,7 +714,7 @@ do_push()
|
||||||
if isnonnull "$src_"
|
if isnonnull "$src_"
|
||||||
then
|
then
|
||||||
append_to @r_revlist "$src_"
|
append_to @r_revlist "$src_"
|
||||||
obj_=$(xecho "$src_" | safe_git_rev_parse)
|
obj_=$(xfeed "$src_" safe_git_rev_parse)
|
||||||
append_to @Refslist "$obj_ $dst_"
|
append_to @Refslist "$obj_ $dst_"
|
||||||
fi
|
fi
|
||||||
done <<EOF
|
done <<EOF
|
||||||
|
|
Loading…
Reference in a new issue