Fix scripts using gawk and wget

This commit is contained in:
Scott Lahteine
2020-08-10 01:44:11 -05:00
parent ce3df42e22
commit 911cdd4d2f
4 changed files with 24 additions and 12 deletions

View File

@ -13,14 +13,17 @@ case "$1" in
-[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
-[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;;
*)
echo "usage: `basename $0` -h | -s" 1>&2
echo "Usage: `basename $0` -h | -s" 1>&2
echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
exit 1
;;
esac
REMOTES=$(git remote -v | egrep "\t$MATCH" | gawk '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/")
which awk >/dev/null && AWK=awk
which gawk >/dev/null && AWK=gawk
REMOTES=$(git remote -v | egrep "\t$MATCH" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/")
if [[ -z $REMOTES ]]; then
echo "Nothing to do." ; exit
@ -29,5 +32,5 @@ fi
echo "$REMOTES" | xargs -n2 git remote set-url
echo -n "Remotes set to $TYPE: "
echo "$REMOTES" | gawk '{printf "%s ", $1}'
echo "$REMOTES" | "$AWK" '{printf "%s ", $1}'
echo