ko1nksm / getoptions

An elegant option/argument parser for shell scripts (full support for bash and all POSIX shells)
Creative Commons Zero v1.0 Universal
406 stars 21 forks source link

Fix SC2004 #49

Closed noraworld closed 1 month ago

noraworld commented 1 year ago

When I use getoptions, I always have to manually ignore SC2004 that ShellCheck points out.

In foo line 62:
          REST="${REST} \"\${$(($OPTIND-$#))}\""
                                ^-----^ SC2004 (style): $/${} is unnecessary on arithmetic variables.

In foo line 68:
        REST="${REST} \"\${$(($OPTIND-$#))}\""
                              ^-----^ SC2004 (style): $/${} is unnecessary on arithmetic variables.

For more information:
  https://www.shellcheck.net/wiki/SC2004 -- $/${} is unnecessary on arithmeti...
    59        --)
    60          shift
    61          while [ $# -gt 0 ]; do
*   62            REST="${REST} \"\${$(($OPTIND-$#))}\""
    63            shift
    64          done
    65          break ;;
    66        [-]?*) set "unknown" "$1"; break ;;
    67        *)
*   68          REST="${REST} \"\${$(($OPTIND-$#))}\""
    69      esac
    70      shift
    71    done

Is it possible to fix this?

ko1nksm commented 2 months ago

The gengetoptions parser has a --shellcheck option that generates shellcheck directives that ignore warnings. However, a bug prevented it from working properly. This bug will be fixed in the next version.

ko1nksm commented 1 month ago

Fixed and released v3.3.1.