Browse code

* fix some missing exits on error conditions fix some typos

Nat! authored on 28-10-2017 11:59:04
Showing 8 changed files
... ...
@@ -1,3 +1,7 @@
1
+### 3.15.1
2
+
3
+* fix some missing exits on error conditions
4
+
1 5
 ## 3.15.0
2 6
 
3 7
 * use a different mechanism for walking repositories during update/upgrade, to catch problems with embedded_repositories of minions not being updated
... ...
@@ -31,7 +31,7 @@
31 31
 #
32 32
 MULLE_EXECUTABLE_VERSION_MAJOR=3
33 33
 MULLE_EXECUTABLE_VERSION_MINOR=15
34
-MULLE_EXECUTABLE_VERSION_PATCH=0
34
+MULLE_EXECUTABLE_VERSION_PATCH=1
35 35
 
36 36
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
37 37
 
... ...
@@ -105,7 +105,7 @@ mulle_bootstrap_usage()
105 105
 
106 106
    cat <<EOF
107 107
 Usage:
108
-   ${MULLE_BOOTSTAP_EXECUTABLE} [flags] [command] [options]
108
+   ${MULLE_BOOTSTRAP_EXECUTABLE} [flags] [command] [options]
109 109
 
110 110
 Flags:
111 111
    -a -y     : default answer to questions (scripts wont be checked)
... ...
@@ -273,6 +273,12 @@ bootstrap_libexec_path()
273 273
 
274 274
 bootstrap_init()
275 275
 {
276
+   if [ "$1" = "version" ]
277
+   then
278
+      echo "${MULLE_EXECUTABLE_VERSION}"
279
+      exit 0
280
+   fi
281
+
276 282
    MULLE_LIBEXEC_PATH="`bootstrap_libexec_path "$0"`"
277 283
    if [ -z "${MULLE_LIBEXEC_PATH}" ]
278 284
    then
... ...
@@ -280,34 +286,29 @@ bootstrap_init()
280 286
       exit 1
281 287
    fi
282 288
 
283
-   PATH="${MULLE_LIBEXEC_PATH}:$PATH"
284
-   export PATH
285
-
286
-   if [ ! -z "${MULLE_BOOTSTRAP_LIBEXEC_TRACE}" ]
287
-   then
288
-      echo "PATH=$PATH" >&2
289
-   fi
290
-
291 289
    #
292 290
    # shell export commands with minimal
293 291
    # trap setup
294 292
    #
295
-   case "${1}" in
293
+   case "$1" in
296 294
       library-path)
297 295
          echo "${MULLE_LIBEXEC_PATH}"
298 296
          exit 0
299 297
       ;;
300 298
 
301
-      version)
302
-         echo "${MULLE_EXECUTABLE_VERSION}"
303
-         exit 0
304
-      ;;
305
-
306 299
       shell)
307 300
          fail "shell has moved to mulle-sde"
308 301
       ;;
309 302
    esac
310 303
 
304
+   PATH="${MULLE_LIBEXEC_PATH}:$PATH"
305
+   export PATH
306
+
307
+   if [ ! -z "${MULLE_BOOTSTRAP_LIBEXEC_TRACE}" ]
308
+   then
309
+      echo "PATH=$PATH" >&2
310
+   fi
311
+
311 312
    #  set -e # more pain then gain in the end
312 313
    #  set -u # doesn't work with my style
313 314
 
... ...
@@ -587,8 +588,8 @@ bootstrap_main()
587 588
       ;;
588 589
 
589 590
       library-path)
590
-         echo "$PATH" | tr ':' '\012' | head -1
591
-         return 0
591
+         echo "${MULLE_LIBEXEC_PATH}"
592
+         exit 0
592 593
       ;;
593 594
 
594 595
       log|logs)
... ...
@@ -51,6 +51,8 @@ seen_check()
51 51
 #
52 52
 _bootstrap_auto_copy()
53 53
 {
54
+   log_debug "_bootstrap_auto_copy" "$@"
55
+
54 56
    local dst="$1"
55 57
    local src="$2"
56 58
    local is_local="$3"
... ...
@@ -146,7 +148,7 @@ _bootstrap_auto_copy()
146 148
                STASHES_DEFAULT_DIR=""
147 149
                STASHES_ROOT_DIR=""
148 150
                merge_repository_files "${filepath}" "${dstfilepath}" "NO"
149
-            )
151
+            ) || exit 1
150 152
             seen="`seen_check "${seen}" "${name}"`"
151 153
          ;;
152 154
 
... ...
@@ -171,7 +173,7 @@ _bootstrap_auto_copy()
171 173
             if [ -z "${match}" ] ## has lowercase (not environment)
172 174
             then
173 175
                log_fluff "Copy expanded value of \"${filepath}\""
174
-               value="`read_expanded_setting "${filepath}" "" "${tmpdir}"`"
176
+               value="`read_expanded_setting "${filepath}" "" "${tmpdir}"`" || exit 1
175 177
                redirect_exekutor "${dstfilepath}" echo "${value}"
176 178
             else
177 179
                exekutor cp -a ${COPYMOVEFLAGS} "${filepath}" "${dstfilepath}" >&2
... ...
@@ -186,6 +188,8 @@ _bootstrap_auto_copy()
186 188
 
187 189
 _bootstrap_create_required_if_needed()
188 190
 {
191
+   log_debug "_bootstrap_create_required_if_needed" "$@"
192
+
189 193
    dst="$1"
190 194
    prefix="$2"
191 195
 
... ...
@@ -220,6 +224,8 @@ _bootstrap_create_required_if_needed()
220 224
 #
221 225
 _bootstrap_auto_create()
222 226
 {
227
+   log_debug "_bootstrap_auto_create" "$@"
228
+
223 229
    local dst="$1"
224 230
    local src="$2"
225 231
 
... ...
@@ -258,11 +264,11 @@ _bootstrap_auto_create()
258 264
 
259 265
 bootstrap_auto_create()
260 266
 {
261
-   log_debug ":bootstrap_auto_create begin:"
267
+   log_debug "bootstrap_auto_create" "$@"
262 268
 
263 269
    _bootstrap_auto_create "${BOOTSTRAP_DIR}.auto" "${BOOTSTRAP_DIR}"
264 270
 
265
-   log_debug ":bootstrap_auto_create end:"
271
+   log_debug "bootstrap_auto_create end"
266 272
 }
267 273
 
268 274
 
... ...
@@ -279,7 +285,7 @@ _bootstrap_merge_expanded_settings_in_front()
279 285
 
280 286
    srcbootstrap="`dirname -- "${1}"`"
281 287
 
282
-   settings1="`read_expanded_setting "$1" "" "${srcbootstrap}"`"
288
+   settings1="`read_expanded_setting "$1" "" "${srcbootstrap}"`" || exit 1
283 289
    if [ ! -z "$2" ]
284 290
    then
285 291
       settings2="`read_setting "$2"`"
... ...
@@ -423,8 +429,7 @@ _bootstrap_auto_special_copy()
423 429
       STASHES_DEFAULT_DIR=""
424 430
       STASHES_ROOT_DIR="${directory}"
425 431
       merge_repository_files "${filepath}" "${dstfilepath}" "NO"
426
-
427
-   )
432
+   ) || exit 1
428 433
 }
429 434
 
430 435
 
... ...
@@ -433,7 +438,6 @@ _bootstrap_auto_embedded_copy()
433 438
    log_debug ":_bootstrap_auto_embedded_copy:"
434 439
 
435 440
    _bootstrap_auto_special_copy "embedded_repositories" "$@"
436
-
437 441
    _bootstrap_create_required_if_needed "${BOOTSTRAP_DIR}.auto/.deep/${name}.d" "embedded_"
438 442
 }
439 443
 
... ...
@@ -36,7 +36,7 @@ _brew_usage()
36 36
 {
37 37
    cat <<EOF >&2
38 38
 Usage:
39
-   ${MULLE_BOOTSTAP_EXECUTABLE}  ${COMMAND} [options] [repositories]
39
+   ${MULLE_BOOTSTRAP_EXECUTABLE}  ${COMMAND} [options] [repositories]
40 40
 
41 41
    You can specify the names of the formulae to ${COMMAND}.
42 42
 
... ...
@@ -362,6 +362,8 @@ _brew_install_brews()
362 362
 
363 363
 brew_install_brews()
364 364
 {
365
+   log_debug "brew_install_brews" "$@"
366
+
365 367
    local unprotect
366 368
 
367 369
    unprotect=
... ...
@@ -400,6 +402,8 @@ brew_fetch_loop()
400 402
 
401 403
 _brew_common_install()
402 404
 {
405
+   log_debug "_brew_common_install" "$@"
406
+
403 407
    if [ $# -ne 0 ]
404 408
    then
405 409
       log_error "Additional parameters not allowed for fetch (" "$@" ")"
... ...
@@ -422,6 +426,8 @@ _brew_common_install()
422 426
 
423 427
 _brew_common_update()
424 428
 {
429
+   log_debug "_brew_common_update" "$@"
430
+
425 431
    if [ $# -ne 0 ]
426 432
    then
427 433
       log_error "Additional parameters not allowed for update (" "$@" ")"
... ...
@@ -434,12 +440,16 @@ _brew_common_update()
434 440
 
435 441
 _brew_common_upgrade()
436 442
 {
443
+   log_debug "_brew_common_upgrade" "$@"
444
+
437 445
    brew_install_brews "upgrade" "$@"
438 446
 }
439 447
 
440 448
 
441 449
 _brew_common_main()
442 450
 {
451
+   log_debug "_brew_common_main" "$@"
452
+
443 453
    [ -z "${MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH}" ] && . mulle-bootstrap-local-environment.sh
444 454
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ]          && . mulle-bootstrap-settings.sh
445 455
 
... ...
@@ -49,7 +49,7 @@ build_usage()
49 49
 
50 50
    cat <<EOF >&2
51 51
 Usage:
52
-   ${MULLE_BOOTSTAP_EXECUTABLE} build [options] [repos]*
52
+   ${MULLE_BOOTSTRAP_EXECUTABLE} build [options] [repos]*
53 53
 EOF
54 54
 
55 55
    cat <<EOF >&2
... ...
@@ -829,6 +829,20 @@ build_log_name()
829 829
 }
830 830
 
831 831
 
832
+add_path_if_exists()
833
+{
834
+   local line="$1"
835
+   local path="$2"
836
+
837
+   if [ -e "${path}" ]
838
+   then
839
+      colon_concat "${line}" "${path}"
840
+   else
841
+      echo "${line}"
842
+   fi
843
+}
844
+
845
+
832 846
 _build_flags()
833 847
 {
834 848
    local configuration="$1"
... ...
@@ -184,7 +184,7 @@ _bail()
184 184
 #         kill -INT $$  # actually useful
185 185
 #      fi
186 186
 #   fi
187
-
187
+   sleep 1
188 188
    exit 1
189 189
 }
190 190
 
... ...
@@ -976,7 +976,7 @@ read_repository_file()
976 976
 
977 977
    srcbootstrap="`dirname -- "${srcfile}"`"
978 978
 
979
-   clones="`read_expanded_setting "$srcfile" "" "${srcbootstrap}"`"
979
+   clones="`read_expanded_setting "${srcfile}" "" "${srcbootstrap}"`" || exit 1
980 980
 
981 981
    local url        # url of clone
982 982
    local dstdir
... ...
@@ -985,7 +985,6 @@ read_repository_file()
985 985
    local tag
986 986
    local name
987 987
 
988
-
989 988
    IFS="
990 989
 "
991 990
    for clone in ${clones}
... ...
@@ -1140,7 +1139,7 @@ merge_repository_files()
1140 1139
    local additions
1141 1140
 
1142 1141
    contents="`cat "${dstfile}" 2> /dev/null || :`"
1143
-   additions="`read_repository_file "${srcfile}" "${delete_dstdir}"`" || fail "Failed to read repository file \"${srcfile}\""
1142
+   additions="`read_repository_file "${srcfile}" "${delete_dstdir}"`" || exit 1
1144 1143
    additions="`echo "${additions}"| sed 's/;*$//'`"
1145 1144
    additions="`merge_repository_contents "${contents}" "${additions}"`"
1146 1145
 
... ...
@@ -1313,7 +1312,7 @@ ${clone}"
1313 1312
 
1314 1313
       filename="${stashdir}/.bootstrap/repositories"
1315 1314
 
1316
-      sub_repos="`read_repository_file "${filename}" "" "${stashdir}/.bootstrap"`"
1315
+      sub_repos="`read_repository_file "${filename}" "" "${stashdir}/.bootstrap"`" || exit 1
1317 1316
 
1318 1317
       if [ ! -z "${sub_repos}" ]
1319 1318
       then
... ...
@@ -777,7 +777,6 @@ read_expanded_setting()
777 777
    [ $# -eq 3 ]             || internal_fail "wrong parameters"
778 778
 
779 779
    local value
780
-   local rval
781 780
 
782 781
    value="`(
783 782
       MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
... ...
@@ -790,11 +789,9 @@ read_expanded_setting()
790 789
       value="${default}"
791 790
    fi
792 791
 
793
-   rval=0
794
-
795 792
    IFS="
796 793
 "
797
-   echo "${value}" | while read line
794
+   for line in ${value}
798 795
    do
799 796
       IFS="${DEFAULT_IFS}"
800 797
 
... ...
@@ -804,7 +801,7 @@ read_expanded_setting()
804 801
          empty_expansion_is_error="`read_config_setting "empty_expansion_is_error" "YES"`"
805 802
          if [ "${empty_expansion_is_error}" = "YES" ]
806 803
          then
807
-           fail "Aborting, because empty expansion warning is an error condition.
804
+            fail "Abort \"${filepath}\" read, because empty expansion warning is an error condition.
808 805
 To disable this:
809 806
    ${C_RESET_BOLD}mulle-bootstrap config -n empty_expansion_is_error"
810 807
          fi
... ...
@@ -812,8 +809,6 @@ To disable this:
812 809
    done
813 810
 
814 811
    IFS="${DEFAULT_IFS}"
815
-
816
-   return $rval
817 812
 }
818 813
 
819 814