From 5e7da5387b4e50cb0674947d599830d8d4c49d89 Mon Sep 17 00:00:00 2001 From: Owolabi Legunsen Date: Tue, 12 Mar 2024 00:10:34 -0400 Subject: [PATCH] edit suggestions on examples (#16) Co-authored-by: Owolabi Legunsen --- examples/anonymous_struct_ex | 4 ++-- examples/flags_details_ex | 4 ++-- examples/flags_ex | 2 +- examples/methods_ex | 6 +++--- examples/shapes_ex | 4 ++-- examples/structs_ex | 8 ++++---- examples/template_ex | 2 +- examples/text_menu_ex | 2 +- examples/to_json_ex | 4 ++-- examples/wait_group_ex | 8 ++++---- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/anonymous_struct_ex b/examples/anonymous_struct_ex index 117bdd5..1f2e663 100755 --- a/examples/anonymous_struct_ex +++ b/examples/anonymous_struct_ex @@ -7,7 +7,7 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # Anonymous structs are created using `amake_` function; this function -# is the same as `make_`, but does not accept `struct` name. +# is the same as `make_`, but does not accept the `struct` name. p=$(amake_ "x" 3 "y" 5) $p x # Output: 3 @@ -21,7 +21,7 @@ function demo() { $a to_string } demo -# Output (different for you depending on time and random number): +# Output (will differ for you, depending on current time and a random number): # { # "date": "Mon 14 Aug 2023 10:22:29 AM CDT", # "rand": "32674" diff --git a/examples/flags_details_ex b/examples/flags_details_ex index 44f180a..b0ccdff 100755 --- a/examples/flags_details_ex +++ b/examples/flags_details_ex @@ -19,8 +19,8 @@ function check_arguments() { fi } -# The following function is some random computation to illustrate the -# way code for parsing can be connected to other/existing code. +# The following function is some random computation to illustrate how +# code for parsing can be connected to other/existing code. function compute_loc() { local -r url="${1}" shift 1 diff --git a/examples/flags_ex b/examples/flags_ex index 2b75930..564138c 100755 --- a/examples/flags_ex +++ b/examples/flags_ex @@ -26,4 +26,4 @@ $flags $ctx parse "$data" "$@" || \ $data to_string # Use data. -echo "Values that you provides are x=$($data x) and z=$($data z)" +echo "The values that you provided are x=$($data x) and z=$($data z)" diff --git a/examples/methods_ex b/examples/methods_ex index f7b0838..c1eceba 100755 --- a/examples/methods_ex +++ b/examples/methods_ex @@ -20,12 +20,12 @@ function Request_curl() { # The first argument of each method is an instance on which # the method was invoked (think of it as `this` or # `self`). Subsequent arguments (if any) are given to the - # method at the invocation time. + # method at invocation time. local -r req="${1}" shift 1 - # Body of the method can be anything. - # Exit code from this method will be propagated to the caller. + # The method body can be anything. + # The exit code from this method will be propagated to the caller. curl "$($req url)" 2>&1 } diff --git a/examples/shapes_ex b/examples/shapes_ex index 11ec6ac..2785607 100755 --- a/examples/shapes_ex +++ b/examples/shapes_ex @@ -15,8 +15,8 @@ function Circle() { make_ $FUNCNAME \ "r" "${r}" - # We do not need to return this explicitly (because the - # default output is the result of the latest command, but + # We do not need to return explicitly (because the + # default output is the result of the last command, but # being explicit is good in some cases). # return $? } diff --git a/examples/structs_ex b/examples/structs_ex index 12e753f..dfca06c 100755 --- a/examples/structs_ex +++ b/examples/structs_ex @@ -6,7 +6,7 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) . ${DIR}/../gobash -# `struct` and `constructor` are one. In any future example, we will +# `struct` and `constructor` are synonyms. In future examples, we will # only use `struct` in text (but we really mean both at once). function Request() { # Normal function arguments in bash. @@ -17,10 +17,10 @@ function Request() { # functions. `make_` allocates an instance. The first # argument is the struct name (think of it as a type). struct # name can be anything, but we will always use $FUNCNAME - # (which is Request in this example). Name is important when + # (which is `Request` in this example). Name is important when # associating methods with a struct (and we love - # $FUNCNAME). The arguments that follow are pairs of a field - # name and value. + # $FUNCNAME). The arguments that follow are the name and value + # of a field. make_ $FUNCNAME \ "url" "${url}" } diff --git a/examples/template_ex b/examples/template_ex index 3961511..465be40 100755 --- a/examples/template_ex +++ b/examples/template_ex @@ -6,7 +6,7 @@ # In summary, it is valuable to always check context at the end of the # execution (even if you do not create your own context, but you rely # on the global context). Of course, you can combine this with your -# regular debugging using -e (which we know is limited) and -x. +# regular debugging, using -e (which is limited) and -x. readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) . ${DIR}/../gobash diff --git a/examples/text_menu_ex b/examples/text_menu_ex index e26a120..448c825 100755 --- a/examples/text_menu_ex +++ b/examples/text_menu_ex @@ -13,7 +13,7 @@ function main() { local menu=$(TextMenu "Pick your favorite color." "$lst") local res=$(UIResult) - # Ask a user to pick an option. + # Ask a user to select an option. $menu show "${res}" # Result keeps the selected value. diff --git a/examples/to_json_ex b/examples/to_json_ex index 5ad667b..fdabdb6 100755 --- a/examples/to_json_ex +++ b/examples/to_json_ex @@ -17,8 +17,8 @@ function Person() { p=$(Person "Jessy" 10) $p to_json -# Although one can override the implementation of `to_json`, such -# changes are not recommended. +# Although one can override the implementation of `to_json`, doing +# so is not recommended. # Output of this script: # { diff --git a/examples/wait_group_ex b/examples/wait_group_ex index ec93c7c..0cadca6 100755 --- a/examples/wait_group_ex +++ b/examples/wait_group_ex @@ -8,14 +8,14 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) function main() { - # This function illustrates the way we create and use + # This function illustrates how we create and use # WaitGroup. However, this example does not really need # WaitGroup as we wait for all sub processes; we can simply # use wait command at the end of the function to wait for - # everything we spawned. The value of this example is to - # illustrate the way to create a WaitGroup, and processes to + # every process that we spawned. The value of this example is to + # illustrate how to create a WaitGroup, processes to # it, and wait (which would be a nice approach if one has to - # wait only for a selected subset of them). + # wait only for a subset of processes). local -r wg=$(WaitGroup)