Browse Source

Fix scripts using gawk and wget

Scott Lahteine 4 years ago
parent
commit
911cdd4d2f

+ 10
- 7
buildroot/bin/use_example_configs View File

@@ -1,18 +1,21 @@
1 1
 #!/usr/bin/env bash
2 2
 
3 3
 IFS=: read -r PART1 PART2 <<< "$@"
4
-[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="$PART2" ; } \
5
-                  || { REPO=bugfix-2.0.x   ; RDIR="$PART1" ; }
4
+[ -n "${PART2}" ] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \
5
+                  || { REPO=bugfix-2.0.x   ; RDIR="${PART1// /%20}" ; }
6 6
 EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples"
7 7
 
8
+which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
9
+which wget >/dev/null && TOOL='wget -q -O wgot'
10
+
8 11
 restore_configs
9 12
 
10 13
 cd Marlin
11 14
 
12
-wget -q "$EXAMPLES/$RDIR/Configuration.h"     -O wgot && mv wgot Configuration.h
13
-wget -q "$EXAMPLES/$RDIR/Configuration_adv.h" -O wgot && mv wgot Configuration_adv.h
14
-wget -q "$EXAMPLES/$RDIR/_Bootscreen.h"       -O wgot && mv wgot _Bootscreen.h
15
-wget -q "$EXAMPLES/$RDIR/_Statusscreen.h"     -O wgot && mv wgot _Statusscreen.h
16
-rm -f wgot
15
+$TOOL "$EXAMPLES/$RDIR/Configuration.h"     >/dev/null 2>&1 && mv wgot Configuration.h
16
+$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration.h
17
+$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h"       >/dev/null 2>&1 && mv wgot Configuration.h
18
+$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h"     >/dev/null 2>&1 && mv wgot Configuration.h
17 19
 
20
+rm -f wgot
18 21
 cd - >/dev/null

+ 4
- 1
buildroot/share/fonts/uxggenpages.sh View File

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

+ 6
- 3
buildroot/share/git/ghtp View File

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

+ 4
- 1
buildroot/share/git/mfclean View File

@@ -6,6 +6,9 @@
6 6
 # Great way to clean up your branches after messing around a lot
7 7
 #
8 8
 
9
+which awk  >/dev/null && AWK=awk
10
+which gawk >/dev/null && AWK=gawk
11
+
9 12
 KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
10 13
 
11 14
 echo "Fetching latest upstream and origin..."
@@ -18,7 +21,7 @@ git branch --merged | egrep -v "^\*|$KEEP" | xargs -n 1 git branch -d
18 21
 echo
19 22
 
20 23
 echo "Pruning Remotely-deleted Branches..."
21
-git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | gawk '{print $1}' | xargs -n 1 git branch -D
24
+git branch -vv | egrep -v "^\*|$KEEP" | grep ': gone]' | "$AWK" '{print $1}' | xargs -n 1 git branch -D
22 25
 echo
23 26
 
24 27
 # List fork branches that don't match local branches

Loading…
Cancel
Save