From cae4c76b56ae1d5623a2c1abd228c5d97e39f4bc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Aug 2020 01:44:11 -0500 Subject: [PATCH] Fix scripts using gawk and wget --- buildroot/bin/use_example_configs | 17 ++++++++++------- buildroot/share/fonts/uxggenpages.sh | 5 ++++- buildroot/share/git/ghtp | 9 ++++++--- buildroot/share/git/mfclean | 5 ++++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/buildroot/bin/use_example_configs b/buildroot/bin/use_example_configs index 96be67e53d..a7fe39a859 100755 --- a/buildroot/bin/use_example_configs +++ b/buildroot/bin/use_example_configs @@ -1,18 +1,21 @@ #!/usr/bin/env bash IFS=: read -r PART1 PART2 <<< "$@" -[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="$PART2" ; } \ - || { REPO=bugfix-2.0.x ; RDIR="$PART1" ; } +[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \ + || { REPO=bugfix-2.0.x ; RDIR="${PART1// /%20}" ; } EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples" +which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' +which wget >/dev/null && TOOL='wget -q -O wgot' + restore_configs cd Marlin -wget -q "$EXAMPLES/$RDIR/Configuration.h" -O wgot && mv wgot Configuration.h -wget -q "$EXAMPLES/$RDIR/Configuration_adv.h" -O wgot && mv wgot Configuration_adv.h -wget -q "$EXAMPLES/$RDIR/_Bootscreen.h" -O wgot && mv wgot _Bootscreen.h -wget -q "$EXAMPLES/$RDIR/_Statusscreen.h" -O wgot && mv wgot _Statusscreen.h -rm -f wgot +$TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h +$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration.h +$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot Configuration.h +$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot Configuration.h +rm -f wgot cd - >/dev/null diff --git a/buildroot/share/fonts/uxggenpages.sh b/buildroot/share/fonts/uxggenpages.sh index 9207835148..46ad438f9c 100755 --- a/buildroot/share/fonts/uxggenpages.sh +++ b/buildroot/share/fonts/uxggenpages.sh @@ -139,11 +139,14 @@ BEGIN { } EOF +which awk >/dev/null && AWK=awk +which gawk >/dev/null && AWK=gawk + grep -Hrn _UxGT . | grep '"' \ | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \ | ${EXEC_GENPAGES} \ | sort -k 1n -k 2n | uniq \ - | gawk -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \ + | "$AWK" -v EXEC_PREFIX=${DN_EXEC} -f "proc.awk" \ | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \ if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \ ${EXEC_BDF2U8G} -u ${PAGE} -b ${BEGIN} -e ${END} ${FN_FONT} fontpage_${PAGE}_${BEGIN}_${END} ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h > /dev/null 2>&1 ; diff --git a/buildroot/share/git/ghtp b/buildroot/share/git/ghtp index f7a6263012..a2fac985dd 100755 --- a/buildroot/share/git/ghtp +++ b/buildroot/share/git/ghtp @@ -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 diff --git a/buildroot/share/git/mfclean b/buildroot/share/git/mfclean index f38997405b..b6ad2b5149 100755 --- a/buildroot/share/git/mfclean +++ b/buildroot/share/git/mfclean @@ -6,6 +6,9 @@ # Great way to clean up your branches after messing around a lot # +which awk >/dev/null && AWK=awk +which gawk >/dev/null && AWK=gawk + KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2" echo "Fetching latest upstream and origin..." @@ -18,7 +21,7 @@ git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d echo echo "Pruning Remotely-deleted Branches..." -git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D +git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | "$AWK" '{print $1}' | xargs -n 1 git branch -D echo # List fork branches that don't match local branches