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

@ -1,18 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
IFS=: read -r PART1 PART2 <<< "$@" IFS=: read -r PART1 PART2 <<< "$@"
[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="$PART2" ; } \ [ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \
|| { REPO=bugfix-2.0.x ; RDIR="$PART1" ; } || { REPO=bugfix-2.0.x ; RDIR="${PART1// /%20}" ; }
EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples" 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 restore_configs
cd Marlin cd Marlin
wget -q "$EXAMPLES/$RDIR/Configuration.h" -O wgot && mv wgot Configuration.h $TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
wget -q "$EXAMPLES/$RDIR/Configuration_adv.h" -O wgot && mv wgot Configuration_adv.h $TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration.h
wget -q "$EXAMPLES/$RDIR/_Bootscreen.h" -O wgot && mv wgot _Bootscreen.h $TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot Configuration.h
wget -q "$EXAMPLES/$RDIR/_Statusscreen.h" -O wgot && mv wgot _Statusscreen.h $TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot Configuration.h
rm -f wgot
rm -f wgot
cd - >/dev/null cd - >/dev/null

View File

@ -139,11 +139,14 @@ BEGIN {
} }
EOF EOF
which awk >/dev/null && AWK=awk
which gawk >/dev/null && AWK=gawk
grep -Hrn _UxGT . | grep '"' \ grep -Hrn _UxGT . | grep '"' \
| sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \ | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
| ${EXEC_GENPAGES} \ | ${EXEC_GENPAGES} \
| sort -k 1n -k 2n | uniq \ | 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 \ | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \ 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 ; ${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 ;

View File

@ -13,14 +13,17 @@ case "$1" in
-[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;; -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
-[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;; -[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-h\e[0m to switch to HTTPS" 1>&2
echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2 echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
exit 1 exit 1
;; ;;
esac 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 if [[ -z $REMOTES ]]; then
echo "Nothing to do." ; exit echo "Nothing to do." ; exit
@ -29,5 +32,5 @@ fi
echo "$REMOTES" | xargs -n2 git remote set-url echo "$REMOTES" | xargs -n2 git remote set-url
echo -n "Remotes set to $TYPE: " echo -n "Remotes set to $TYPE: "
echo "$REMOTES" | gawk '{printf "%s ", $1}' echo "$REMOTES" | "$AWK" '{printf "%s ", $1}'
echo echo

View File

@ -6,6 +6,9 @@
# Great way to clean up your branches after messing around a lot # 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" KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
echo "Fetching latest upstream and origin..." echo "Fetching latest upstream and origin..."
@ -18,7 +21,7 @@ git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d
echo echo
echo "Pruning Remotely-deleted Branches..." 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 echo
# List fork branches that don't match local branches # List fork branches that don't match local branches