better-comments-next icon indicating copy to clipboard operation
better-comments-next copied to clipboard

Shellscript: '#' in Bash internal variable "$#" shouldn't be treated as a comment character.

Open akwala opened this issue 7 months ago • 2 comments

See screenshot below. The ! is part of an arithmetic operator, but is interpreted as a better-comments-next tag.

Image

akwala avatar May 12 '25 22:05 akwala

There should be something wrong before this line, show me the full code.

edwinhuish avatar May 13 '25 07:05 edwinhuish

~~~~~ in the first line is a BCN tag.

 # ~~~~~[Block:arg_validation]...
  {
    if (($# != 3)); then
      l0gCode_return "$E_MISSING_OR_EXTRA_ARGS"
    elif [ -z "$1" ] || [ -z "$2" ]; then # verify that args 1 & 2 are non-null
      l0gCode_return "$E_NULL_OR_MISSING_ARG"
    elif ! isIntP "$3"; then # verify that arg 3 is a positive int
      l0gCode_return "$E_INVALID_ARG" \
        "Third arg, 'days_older_than_to_delete', must be a positive int."
    else
      :
    fi
  } || {
    ((rtn_code = $?))
    l0ginfo "$usage"
    return $rtn_code
  }

akwala avatar May 13 '25 17:05 akwala