shift contents of long $() into filter_ids()
This was prompted by the fact that posh does not deal with $() that contains comments where the comment includes an odd number of single-quotes. It seems to get befuddled into trying to find the matching quote. Regardless, making a function for filtering the unneeded ids seems much neater than avoiding apostrophes, so that's what I've done. SSH-Copy-ID-Upstream: 3dab3366a584427045c8a690a93282f02c09cf24
This commit is contained in:
parent
fd36017459
commit
e545d94b71
|
@ -169,26 +169,16 @@ if [ -z "$(eval $GET_ID)" ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# populate_new_ids() uses several global variables ($USER_HOST, $SSH_OPTS ...)
|
||||
# and has the side effect of setting $NEW_IDS
|
||||
populate_new_ids() {
|
||||
# filter_ids()
|
||||
# tries to log in using the keys piped to it, and filters out any that work
|
||||
filter_ids() {
|
||||
L_SUCCESS="$1"
|
||||
L_TMP_ID_FILE="$SCRATCH_DIR"/popids_tmp_id
|
||||
L_OUTPUT_FILE="$SCRATCH_DIR"/popids_output
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
if [ "$FORCED" ] ; then
|
||||
NEW_IDS=$(eval $GET_ID)
|
||||
return
|
||||
fi
|
||||
|
||||
# repopulate "$@" inside this function
|
||||
eval set -- "$SSH_OPTS"
|
||||
|
||||
printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
|
||||
# shellcheck disable=SC2086
|
||||
NEW_IDS=$(
|
||||
eval $GET_ID | {
|
||||
while read -r ID || [ "$ID" ] ; do
|
||||
printf '%s\n' "$ID" > "$L_TMP_ID_FILE"
|
||||
|
||||
|
@ -216,8 +206,20 @@ populate_new_ids() {
|
|||
|
||||
cat "$L_TMP_ID_FILE"
|
||||
done
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# populate_new_ids() uses several global variables ($USER_HOST, $SSH_OPTS ...)
|
||||
# and has the side effect of setting $NEW_IDS
|
||||
populate_new_ids() {
|
||||
if [ "$FORCED" ] ; then
|
||||
# shellcheck disable=SC2086
|
||||
NEW_IDS=$(eval $GET_ID)
|
||||
return
|
||||
fi
|
||||
|
||||
printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
|
||||
# shellcheck disable=SC2086
|
||||
NEW_IDS=$(eval $GET_ID | filter_ids $1)
|
||||
|
||||
if expr "$NEW_IDS" : "^ERROR: " >/dev/null ; then
|
||||
printf '\n%s: %s\n\n' "$0" "$NEW_IDS" >&2
|
||||
|
|
Loading…
Reference in New Issue