Shell script cleanups #10773

pull practicalswift wants to merge 8 commits into bitcoin:master from practicalswift:shell changing 7 files +10 −14
  1. practicalswift commented at 11:05 AM on July 8, 2017: contributor

    Shell script cleanups:

    • Add required space to [ -n ].
    • Avoid quote within quote.
    • Exit if cd fails.
    • Remove \n which is not handled by echo.
    • Remove redundant $ in arithmetic variable expression.
    • Use $(command) instead of legacy form `command`.
    • Arrays are not supported in POSIX sh. Use bash when arrays are used.
    • [ foo -a bar ] is not well defined, use [ foo ] && [ bar ] instead.
    • [ foo -o bar ] is not well defined, use [ foo ] || [ bar ] instead.
  2. fanquake added the label Refactoring on Jul 8, 2017
  3. fanquake added the label Scripts and tools on Jul 8, 2017
  4. practicalswift force-pushed on Jul 8, 2017
  5. gmaxwell commented at 11:37 AM on July 9, 2017: contributor

    do we have someone on OpenBSD or likewise to test this?

  6. MarcoFalke commented at 9:42 AM on September 14, 2017: member
  7. practicalswift force-pushed on Sep 14, 2017
  8. practicalswift commented at 9:51 AM on September 14, 2017: contributor

    @MarcoFalke Fixed! :-)

  9. laanwj commented at 1:15 PM on October 2, 2017: member

    do we have someone on OpenBSD or likewise to test this?

    We don't have any tests for most of these scripts, period :(

  10. TheBlueMatt commented at 8:18 PM on October 3, 2017: member

    With the exception of the sh -> bash change when needed and clear fixes for edge cases (eg the || exit 1s), both of which I think we should do, I'm not sure what this accomplishes aside from code churn...are the other things going to break on some shell, or are they deprecated in a way that they will be removed within the next ~decade? We've had plenty of issues with otherwise innocuous shell script changes breaking dash-based systems, not to mention BSD incompatibilities, plus now WSL, so there is nontrivial review for some of these things, if its just because they are prettier or feel nicer, I really think we should cut back some of these changes.

  11. practicalswift force-pushed on Oct 4, 2017
  12. practicalswift force-pushed on Oct 4, 2017
  13. practicalswift commented at 7:49 PM on October 4, 2017: contributor

    @TheBlueMatt Thanks for reviewing.

    I've now removed the changes that could be claimed to be in the "deprecated but not likely to be removed any time soon" and the "feels prettier/nicer" categories.

    I've also unsquashed the changes so that this PR can be reviewed on a more detailed per-change/commit level. The requested squashing was perhaps a bit premature. I'll squash again when the only ACK:ed changes remain :-)

    The remaining changes are:

    1. Remove unused variables Rationale: Obvious mistake corrected.

    2. Remove "\n" from echo argument. echo does not support escape sequences. Rationale: Obvious mistake corrected - echo "\n" prints a backslash, the letter n and a newline.

    3. Add error handling: exit if cd fails Rationale: Obvious mistake corrected - missing error handling.

    4. Add required space to [[ -n "$1" ]] (previously [[ -n"$1" ]]) Rationale: Obvious mistake corrected - the syntax is [[ -n STRING ]], not [[ -nSTRING ]].

    5. Fix incorrect quoting of quotes (the previous quotes had no effect beyond unquoting) Rationale: echo "1 "2" 3" prints 1 2 3 and not 1 "2" 3. Change to echo "1 \"2\" 3" where quotes are intended in the output.

    6. Use bash instead of POSIX sh. POSIX sh does not support arrays. Rationale: Assumptions are better stated explicitly than implicitly :-) @TheBlueMatt How do you feel about the remaining changes? All of those clear fixes? :-)

  14. TheBlueMatt commented at 3:02 PM on October 5, 2017: member

    utACK 6c6494092e57e78bed4b6f2b315ed3e9d328ad9f

  15. in contrib/verify-commits/verify-commits.sh:39 in 6c6494092e outdated
      35 | @@ -38,8 +36,8 @@ PREV_COMMIT=""
      36 |  
      37 |  while true; do
      38 |  	if [ "$CURRENT_COMMIT" = $VERIFIED_ROOT ]; then
      39 | -		echo "There is a valid path from "$CURRENT_COMMIT" to $VERIFIED_ROOT where all commits are signed!"
      40 | -		exit 0;
      41 | +		echo "There is a valid path from \"$CURRENT_COMMIT\" to $VERIFIED_ROOT where all commits are signed!"
    


    MarcoFalke commented at 6:34 PM on October 9, 2017:

    According to the line above this is only printed when both vars are the same. No need to print them both.


    practicalswift commented at 7:15 PM on October 9, 2017:

    @MarcoFalke Do you have any suggestion regarding the correct output to print? :-)


    MarcoFalke commented at 7:55 PM on October 9, 2017:

    maybe

     PREV_COMMIT=""
    +INITIAL_COMMIT=${CURRENT_COMMIT}
     
     while true; do
     	if [ "$CURRENT_COMMIT" = $VERIFIED_ROOT ]; then
    -		echo "There is a valid path from "$CURRENT_COMMIT" to $VERIFIED_ROOT where all commits are signed!"
    +		echo "There is a valid path from \"$INITIAL_COMMIT\" to $VERIFIED_ROOT where all commits are signed!"
    
  16. MarcoFalke commented at 6:34 PM on October 9, 2017: member

    utACK 6c6494092

  17. practicalswift commented at 9:22 PM on October 9, 2017: contributor

    @MarcoFalke Fixed. Would you mind re-reviewing? :-)

  18. in contrib/verify-commits/verify-commits.sh:36 in 0b6ebcf4c4 outdated
      32 | @@ -33,10 +33,11 @@ fi
      33 |  
      34 |  NO_SHA1=1
      35 |  PREV_COMMIT=""
      36 | +INITIAL_COMMIT=${CURRENT_COMMIT}
    


    TheBlueMatt commented at 9:25 PM on October 17, 2017:

    In quotes, please.

  19. practicalswift commented at 5:35 AM on October 18, 2017: contributor

    @TheBlueMatt Fixed! :-)

  20. Remove unused variables f6b3382fa3
  21. Remove "\n" from echo argument. echo does not support escape sequences. b9e79ab415
  22. Add error handling: exit if cd fails 1e44ae0e19
  23. Add required space to [[ -n "$1" ]] (previously [[ -n"$1" ]]) 564a172dfd
  24. Fix incorrect quoting of quotes (the previous quotes had no effect beyond unquoting) 80f5f28d38
  25. Use bash instead of POSIX sh. POSIX sh does not support arrays. 193c2fb4c8
  26. Fix valid path output 683b9d280b
  27. Add quotes to variable assignment (as requested by @TheBlueMatt) 13a81b19df
  28. practicalswift force-pushed on Oct 18, 2017
  29. practicalswift commented at 3:10 PM on October 18, 2017: contributor

    Rebased!

  30. MarcoFalke commented at 8:21 PM on October 18, 2017: member

    Note, you can go ahead and squash fixup commits when you are doing a rebase anyway.

  31. practicalswift commented at 8:27 PM on October 18, 2017: contributor

    @MarcoFalke Good idea! Now squashed. Would you mind re-reviewing? :-)

  32. TheBlueMatt commented at 4:31 PM on November 7, 2017: member

    utACK 13a81b19df7acff51187655bb755f1371f9c83ca

  33. MarcoFalke commented at 4:48 PM on November 10, 2017: member

    utACK 13a81b1 (Only looked at the diff, didn't check that the 8 commits do what they advertise)

  34. practicalswift commented at 7:09 AM on November 30, 2017: contributor

    Ready for merge? :-)

  35. theuni commented at 6:21 PM on December 4, 2017: member

    utACK 13a81b19df7acff51187655bb755f1371f9c83ca

  36. sipa commented at 9:18 PM on December 4, 2017: member

    utACK 13a81b19df7acff51187655bb755f1371f9c83ca

  37. MarcoFalke assigned laanwj on Dec 4, 2017
  38. sipa merged this on Dec 4, 2017
  39. sipa closed this on Dec 4, 2017

  40. sipa referenced this in commit c17f11f7b4 on Dec 4, 2017
  41. PastaPastaPasta referenced this in commit 14668c9d36 on Mar 27, 2020
  42. PastaPastaPasta referenced this in commit 8c19779572 on Mar 28, 2020
  43. PastaPastaPasta referenced this in commit d50d317a64 on Mar 29, 2020
  44. PastaPastaPasta referenced this in commit 2906e4baa9 on Mar 31, 2020
  45. UdjinM6 referenced this in commit c9786d3714 on Mar 31, 2020
  46. PastaPastaPasta referenced this in commit a7a3ecc354 on Apr 1, 2020
  47. zkbot referenced this in commit b61a7e2e89 on Oct 27, 2020
  48. ckti referenced this in commit 89f22e3b34 on Mar 28, 2021
  49. practicalswift deleted the branch on Apr 10, 2021
  50. gades referenced this in commit a5f34404c8 on May 2, 2022
  51. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me