You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the bellow is used to process numeric option values, however, it has a hard limit on the number of digits in the input. Even if the input shouldn't be that large, it should still match so the correct error message and return code may be provided.
# Strip space character(s) from argument.
arg=$(echo $arg | tr -d '[:space:]')
# Ensure provided line length is valid.
case "$arg" in
# TODO #45: Figure out how to remove this hard coded line length digit limit. Then update tests to verify it.
[[:digit:]]|[[:digit:]][[:digit:]]|[[:digit:]][[:digit:]][[:digit:]]|[[:digit:]][[:digit:]][[:digit:]][[:digit:]]|[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]])
len=$(($arg+$len)) ;;
*)
echo "$createHeaderFooterLogPrefix Line length must be a non-negative integer, was '$arg', see doc:" >&2
echo "$CREATE_HEADER_FOOTER_DOC" >&2
exit 141 ;;
##To Reproduce##
Steps to reproduce the behavior:
Call a shell script with an option value that contains, say, 10 digits.
Script will say the option name was invalid (that's wrong).
##Expected Behavior##
Any number of digits should match, error checking may be done after.
##Actual Behavior##
If you pass in a number with more digits that the code is hard coded for, then script will say you provided an invalid option when you really didn't.
2023/04/11 17:56:57 MDT ERROR output(): Indent must be a non-negative integer, was '9999999999', see doc:
#/ DESCRIPTION:
#/ Used to produce formatted output.
#/ - Example 1:
#/ #############
#/ ## Some Text ##
#/ #############
#/ - Example 2:
#/ ## Some Text ##
#/
#/ USAGE: output [OPTIONS]... -m="message text"...
#/
#/ NOTE(S):
#/ - Method may not use the log function because this is used by that method.
#/
#/ OPTION(S):
#/ -h, --help
#/ Print this help message. Function will return code of '0'. No processing will be done.
#/ (OPTIONAL)
#/ -m=<msg>, --msg=<msg>
#/ Message user would like formatted output produced of.
#/ - Note: If multiple are given, each will show up on a new line.
#/ - Note: If one line exceeds the set max line length, it will be
#/ broken up. The est of the line will start with the same
#/ inditation.
#/ - Note: '\t' and '\n\ will be handled as the 'printf' function would.
#/ - Note: At least one instance of this option must be provided.
#/ (REQUIRED)
#/ -p, --pretty
#/ When given, message produced will include a header, footer, prefix, and postfix.
#/ - Note: Does the same as giving: --header-footer, and --pre-post-fix.
#/ - Note: When given: --p, --header-footer, and --pre-post-fix become
#/ redundant.
#/ (OPTIONAL)
#/ --pp, --pre-post-fix
#/ When given, message produced will include a prefix and postfix.
#/ - Note: Redundant if -p.
#/ (OPTIONAL)
#/ -l=<maxLineLength>, --line-length=<maxLineLength>
#/ Sets max number of characters that may be included on a single line.
#/ - Note: Line length includes prefix and postfix if included.
#/ - Note: Default value: 100.
#/ (OPTIONAL)
#/ --header-footer
#/ When given, message produced will include a header and footer.
#/ - Note: Redundant if -p given.
#/ (OPTIONAL)
#/ -f=<formattingCharacter>, --formatting-character=<formattingCharacter>
#/ Sets character used by header, footer, prefix, and postfix.
#/ - Note: Default value: $DEFAULT_CHAR.
#/ - Note: Some special characters may require two to be given (ex. -f="%%").
#/ - Note: Some *other* special characters may not work at all (ex. back slash).
#/ (OPTIONAL)
#/ --indent=<numSpacesToIndent>
#/ Sets number of spaces formatted message, including
#/ prefix/postfix/header/footer if used, should be indented.
#/ - Note: Default value: $DEFAULT_INDENT.
#/ - Note: Must be a positive integer.
#/ (OPTIONAL)
#/ -t, --trace
#/ When given, *trace* formatting character ($TRACE_CHAR) is used as formatting character.
#/ - Note: If the formatting character isn't set, and no level is
#/ provided (ex. debug, error), then the default formatting
#/ character ($DEFAULT_CHAR) is used.
#/ (OPTIONAL)
#/ -d, --debug
#/ When given, *debug* formatting character ($DEBUG_CHAR) is used as
#/ formatting character.
#/ - Note: If the formatting character isn't set, and no level is
#/ provided (ex. debug, error), then the default formatting
#/ character ($DEFAULT_CHAR) is used.
#/ (OPTIONAL)
#/ -i, --info
#/ When given, *info* formatting character ($INFO_CHAR) is used as
#/ formatting character.
#/ - Note: If the formatting character isn't set, and no level is
#/ provided (ex. debug, error), then the default formatting
#/ character ($DEFAULT_CHAR) is used.
#/ (OPTIONAL)
#/ -w, --warn
#/ When given, *warn* formatting character ($WARN_CHAR) is used as
#/ formatting character.
#/ - Note: If the formatting character isn't set, and no level is
#/ provided (ex. debug, error), then the default formatting
#/ character ($DEFAULT_CHAR) is used.
#/ (OPTIONAL)
#/ -e, --error
#/ When given, *error* formatting character ($ERROR_CHAR) is used as
#/ formatting character.
#/ - Note: If the formatting character isn't set, and no level is
#/ provided (ex. debug, error), then the default formatting
#/ character ($DEFAULT_CHAR) is used.
#/ (OPTIONAL)
#/
#/ RETURN CODE(S):
#/ - 0: Returned when:
#/ - Help message is requested and produced.
#/ - Processing is successful.
#/ - 3: Returned when header/footer fails to be generated.
#/ - 140: Returned when given option name is invalid.
#/ - 141: Returned when:
#/ - Provided indent value is negative.
#/ - Provided max line length value is too small:
#/ - Line length - prefix - postfix > 0.
#/ - No message text is provided.
#/ - 142: Returned when the message text option is not provided.
#/
#/ EXAMPLE(S):
#/ output --help
#/ output -m="line 1" -m="line 2" -m="line 3\nline 4" -m="line 5"
#/ output -m="line 1" -m="longline 2" -l=6
#/ output -m="line 1" -m="longline 2" -l=10 -p
#/ output -m="line 1" -m="longline 2" -l=10 --pre-post-fix --header-footer
#/ output -m="line 1" --pretty --error
#/ output -m="line 1" -p -w
#/ output -m="line 1" -p -f="^"
#/ output -m="line 1" -p --formatting-character="&&"
#/
#/ TODO(S):
#/ - Implement: Dynamically determine, based on last character of line being
#/ split up, if a '-' is needed.
#/ - Implement: Ability to append end of line that was too long to fit on one
#/ row to the start of the next line.
#/ - Implement: Support for '%' as a formatting character.
$?: '141'
##Environment##
OS:
Name: Fedora
Version: 37
Shell:
Name: bash
Version: 5.2.15(1)-release
##Blocked By##
None.
##Blocking##
None.
##Additional Context##
TODO comments are included in the code in each place that this bug is known to exist. Just search code for this issue ID (e.g. #45).
The text was updated successfully, but these errors were encountered:
##Describe the Bug##
Currently the bellow is used to process numeric option values, however, it has a hard limit on the number of digits in the input. Even if the input shouldn't be that large, it should still match so the correct error message and return code may be provided.
##To Reproduce##
Steps to reproduce the behavior:
##Expected Behavior##
Any number of digits should match, error checking may be done after.
##Actual Behavior##
If you pass in a number with more digits that the code is hard coded for, then script will say you provided an invalid option when you really didn't.
##Screenshots##
Input:
output -m=m --msg=s -m=g -p --indent=9999999999;echo "\$?: '$?'"
Output:
##Environment##
##Blocked By##
##Blocking##
##Additional Context##
TODO
comments are included in the code in each place that this bug is known to exist. Just search code for this issue ID (e.g. #45).The text was updated successfully, but these errors were encountered: