Browse code

fix color output by using printf

Nat! authored on 04/01/2016 01:26:54
Showing 6 changed files
... ...
@@ -1,3 +1,7 @@
1
+0.13
2
+===
3
+   Fix colorization by using printf, instead of echo.
4
+
1 5
 0.12
2 6
 ===
3 7
    Run post-install.sh also on embedded repositories. Sometimes useful, when
... ...
@@ -6,7 +6,7 @@
6 6
 if [ "${MULLE_BOOTSTRAP_NO_COLOR}" != "YES" ]
7 7
 then
8 8
    case `uname` in
9
-      Darwin|Linux)
9
+      Darwin|Linux|FreeBSD)
10 10
          # Escape sequence and resets
11 11
          C_RESET="\033[0m"
12 12
 
... ...
@@ -48,7 +48,7 @@ do
48 48
    mkdir -p "${bin}" 2> /dev/null
49 49
    sed "s|/usr/local/libexec/mulle-bootstrap|${libexec}|g" < "${i}" > "${bin}/$i" || exit 1
50 50
    chmod "${mode}" "${bin}/${i}" || exit 1
51
-   echo "install: ${C_MAGENTA}$bin/$i${C_RESET}" >&2
51
+   printf "install: ${C_MAGENTA}%s${C_RESET}\n" "$bin/$i" >&2
52 52
 done
53 53
 
54 54
 
... ...
@@ -61,8 +61,8 @@ done
61 61
 if [ -d "test" ]
62 62
 then
63 63
    # use attractive colors :)
64
-   echo "${C_GREEN}If you are new to mulle-bootstrap I would suggest checking out" >&2
65
-   echo "the ${C_YELLOW}README.md${C_GREEN} in ${C_CYAN}./test${C_GREEN} and doing the examples." >&2
64
+   printf "${C_GREEN}If you are new to mulle-bootstrap I would suggest checking out\n" >&2
65
+   printf "the ${C_YELLOW}README.md${C_GREEN} in ${C_CYAN}./test${C_GREEN} and doing the examples.\n" >&2
66 66
 fi
67 67
 
68 68
 # for people who source us
... ...
@@ -29,7 +29,7 @@
29 29
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 
32
-VERSION=0.12
32
+VERSION=0.13
33 33
 
34 34
 #
35 35
 # This is the main user interface to mulle-bootstrap
... ...
@@ -393,6 +393,7 @@ bootstrap_auto_update()
393 393
    log_info "Recursively acquiring ${dir} .bootstrap settings ..."
394 394
 
395 395
    local old
396
+   local name
396 397
 
397 398
    old="${IFS:-" "}"
398 399
 
... ...
@@ -419,7 +420,8 @@ bootstrap_auto_update()
419 419
             then
420 420
                exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
421 421
             else
422
-               log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
422
+               name="`basename -- "${i}"`"
423
+               log_fluff "Setting \"${name}\" is not specified, so not inherited"
423 424
             fi
424 425
          fi
425 426
       done
... ...
@@ -446,9 +448,10 @@ bootstrap_auto_update()
446 446
       IFS="{old}"
447 447
       srcfile="${dir}/.bootstrap/${i}"
448 448
       dstfile="${BOOTSTRAP_SUBDIR}.auto/${i}"
449
+      name="`basename -- "${i}"`"
449 450
       if [ -f "${srcfile}" ]
450 451
       then
451
-         log_fluff "Inheriting \"`basename -- ${i}`\" from \"${srcfile}\""
452
+         log_fluff "Inheriting \"${name}\" from \"${srcfile}\""
452 453
 
453 454
          mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/`dirname -- "${i}"`"
454 455
          if [ -f "${BOOTSTRAP_SUBDIR}.auto/${i}" ]
... ...
@@ -464,7 +467,7 @@ bootstrap_auto_update()
464 464
             exekutor cp "${srcfile}" "${dstfile}" || exit 1
465 465
          fi
466 466
       else
467
-         log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
467
+         log_fluff "Setting \"${name}\" is not specified, so not inherited"
468 468
       fi
469 469
    done
470 470
    IFS="{old}"
... ...
@@ -34,7 +34,7 @@
34 34
 if [ "${MULLE_BOOTSTRAP_NO_COLOR}" != "YES" ]
35 35
 then
36 36
    case `uname` in
37
-      Darwin|Linux)
37
+      Darwin|Linux|FreeBSD)
38 38
          C_RESET="\033[0m"
39 39
 
40 40
          # Foreground colours
... ...
@@ -53,7 +53,7 @@ fi
53 53
 C_ERROR="${C_RED}"
54 54
 log_error()
55 55
 {
56
-   echo "${C_ERROR}$*${C_RESET}" >&2
56
+   printf "${C_ERROR}%b${C_RESET}\n" "$*" >&2
57 57
 }
58 58
 
59 59
 
... ...
@@ -62,7 +62,7 @@ log_warning()
62 62
 {
63 63
    if [ "${MULLE_BOOTSTRAP_TERSE}" != "YES" ]
64 64
    then
65
-      echo "${C_WARNING}$*${C_RESET}" >&2
65
+      printf "${C_WARNING}%b${C_RESET}\n" "$*" >&2
66 66
    fi
67 67
 }
68 68
 
... ...
@@ -72,7 +72,7 @@ log_info()
72 72
 {
73 73
    if [ "${MULLE_BOOTSTRAP_TERSE}" != "YES" ]
74 74
    then
75
-      echo "${C_INFO}$*${C_RESET}" >&2
75
+      printf "${C_INFO}%b${C_RESET}\n" "$*" >&2
76 76
    fi
77 77
 }
78 78
 
... ...
@@ -82,7 +82,7 @@ log_fluff()
82 82
 {
83 83
    if [ "${MULLE_BOOTSTRAP_VERBOSE}" = "YES"  ]
84 84
    then
85
-      echo "${C_FLUFF}$*${C_RESET}" >&2
85
+      printf "${C_FLUFF}%b${C_RESET}\n" "$*" >&2
86 86
    fi
87 87
 }
88 88
 
... ...
@@ -90,14 +90,14 @@ log_fluff()
90 90
 C_TRACE="${C_FLUFF}"
91 91
 log_trace()
92 92
 {
93
-   echo "${C_TRACE}$*${C_RESET}" >&2
93
+   printf "${C_TRACE}%b${C_RESET}" "$*" >&2
94 94
 }
95 95
 
96 96
 
97 97
 C_TRACE2="${C_RESET}"
98 98
 log_trace2()
99 99
 {
100
-   echo "${C_TRACE2}$*${C_RESET}" >&2
100
+   printf "${C_TRACE2}%b${C_RESET}" "$*" >&2
101 101
 }
102 102
 
103 103
 
... ...
@@ -430,7 +430,7 @@ user_say_yes()
430 430
   x=`read_config_setting "answer" "ASK"`
431 431
   while [ "$x" != "Y" -a "$x" != "YES" -a  "$x" != "N"  -a  "$x" != "NO"  -a "$x" != "" ]
432 432
   do
433
-     echo "${C_BR_YELLOW}$* ${C_YELLOW}(${C_RESET}y${C_YELLOW}/${C_GREEN}N${C_YELLOW})${C_RESET}" >&2
433
+     printf "${C_BR_YELLOW}%b ${C_YELLOW}(${C_RESET}y${C_YELLOW}/${C_GREEN}N${C_YELLOW})${C_RESET} >" "$*" >&2
434 434
      read x
435 435
      x=`echo "${x}" | tr '[:lower:]' '[:upper:]'`
436 436
   done
... ...
@@ -257,9 +257,9 @@ Release"
257 257
       if [ $terse -ne 0 ]
258 258
       then
259 259
          #     012345678901234567890123456789012345678901234567890123456789
260
-         echo "${C_RESET}Settings will be added to ${C_MAGENTA}${projectname}${C_RESET}." >&2
261
-         echo "In the long term it may be more useful to copy/paste the following" >&2
262
-         echo "lines into a local .xcconfig file, that is inherited by all configurations.${C_RESET}" >&2
260
+         printf "${C_RESET}Settings will be added to ${C_MAGENTA}${projectname}${C_RESET}.\n" >&2
261
+         printf "In the long term it may be more useful to copy/paste the following\n" >&2
262
+         printf "lines into a local .xcconfig file, that is inherited by all configurations.${C_RESET}\n" >&2
263 263
       fi
264 264
    else
265 265
       flag="remove"
... ...
@@ -267,8 +267,8 @@ Release"
267 267
       if [ $terse -ne 0 ]
268 268
       then
269 269
          #     012345678901234567890123456789012345678901234567890123456789
270
-         echo "${C_RESET}Settings will be removed from ${projectname}." >&2
271
-         echo "You may want to check afterwards, that this has worked out OK :).${C_RESET}" >&2
270
+         printf "${C_RESET}Settings will be removed from ${projectname}.\n" >&2
271
+         printf "You may want to check afterwards, that this has worked out OK :).${C_RESET}\n" >&2
272 272
       fi
273 273
    fi
274 274
 
... ...
@@ -318,7 +318,7 @@ Release"
318 318
          local mapped
319 319
          local i
320 320
 
321
-         echo  "${C_RESET}-----------------------------------------------------------"  >&2
321
+         printf  "${C_RESET}-----------------------------------------------------------\n"  >&2
322 322
 
323 323
          #  make these echos easily grabable by stdout
324 324
          #     012345678901234567890123456789012345678901234567890123456789
... ...
@@ -346,7 +346,7 @@ Release"
346 346
          done
347 347
 
348 348
          IFS="${old}"
349
-         echo  "-----------------------------------------------------------${C_RESET}"  >&2
349
+         printf  "-----------------------------------------------------------${C_RESET}\n"  >&2
350 350
       fi
351 351
 
352 352
       query="Add ${C_CYAN}${DEPENDENCY_SUBDIR}/${LIBRARY_DIR_NAME}${C_YELLOW} and friends to search paths of ${C_MAGENTA}${projectname}${C_YELLOW} ?"
... ...
@@ -371,14 +371,14 @@ Release"
371 371
       if [ $terse -ne 0 ]
372 372
       then
373 373
          #     012345678901234567890123456789012345678901234567890123456789
374
-         echo "${C_RESET}"
374
+         printf "${C_RESET}\n"
375 375
          echo "Hint:"
376 376
          echo "If you add a configuration to your project, remember to edit" >&2
377 377
          echo "the LIBRARY_CONFIGURATION setting for that configuration." >&2
378 378
          echo "" >&2
379 379
          echo "You can rerun setup-xcode at later times and it should not" >&2
380 380
          echo "unduly duplicate setting contents." >&2
381
-         echo "${C_RESET}" >&2
381
+         printf "${C_RESET}\n" >&2
382 382
       fi
383 383
    fi
384 384
 }