Browse Source

Fix scripts using gawk and wget

Scott Lahteine 3 years ago
parent
commit
911cdd4d2f

+ 10
- 7
buildroot/bin/use_example_configs View File

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 
2
 
3
 IFS=: read -r PART1 PART2 <<< "$@"
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
 EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples"
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
 restore_configs
11
 restore_configs
9
 
12
 
10
 cd Marlin
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
 cd - >/dev/null
21
 cd - >/dev/null

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

139
 }
139
 }
140
 EOF
140
 EOF
141
 
141
 
142
+which awk  >/dev/null && AWK=awk
143
+which gawk >/dev/null && AWK=gawk
144
+
142
 grep -Hrn _UxGT . | grep '"' \
145
 grep -Hrn _UxGT . | grep '"' \
143
   | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
146
   | sed 's/_UxGT("/\n&/g;s/[^\n]*\n_UxGT("\([^"]*\)[^\n]*/\1 /g;s/.$//' \
144
   | ${EXEC_GENPAGES} \
147
   | ${EXEC_GENPAGES} \
145
   | sort -k 1n -k 2n | uniq \
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
   | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
150
   | while read PAGE BEGIN END UTF8BEGIN UTF8END; do \
148
     if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
151
     if [ ! -f ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h ]; then \
149
       ${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 ;
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
   -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
13
   -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
14
   -[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;;
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
     echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
17
     echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
18
     echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
18
     echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
19
     exit 1
19
     exit 1
20
     ;;
20
     ;;
21
 esac
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
 if [[ -z $REMOTES ]]; then
28
 if [[ -z $REMOTES ]]; then
26
   echo "Nothing to do." ; exit
29
   echo "Nothing to do." ; exit
29
 echo "$REMOTES" | xargs -n2 git remote set-url
32
 echo "$REMOTES" | xargs -n2 git remote set-url
30
 
33
 
31
 echo -n "Remotes set to $TYPE: "
34
 echo -n "Remotes set to $TYPE: "
32
-echo "$REMOTES" | gawk '{printf "%s ", $1}'
35
+echo "$REMOTES" | "$AWK" '{printf "%s ", $1}'
33
 echo
36
 echo

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

6
 # Great way to clean up your branches after messing around a lot
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
 KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
12
 KEEP="RC|RCBugFix|dev|master|bugfix-1|bugfix-2"
10
 
13
 
11
 echo "Fetching latest upstream and origin..."
14
 echo "Fetching latest upstream and origin..."
18
 echo
21
 echo
19
 
22
 
20
 echo "Pruning Remotely-deleted Branches..."
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
 echo
25
 echo
23
 
26
 
24
 # List fork branches that don't match local branches
27
 # List fork branches that don't match local branches

Loading…
Cancel
Save