]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix vmtest.sh getopts optstring
authorDaniel Xu <dxu@dxuuu.xyz>
Tue, 9 Aug 2022 17:11:10 +0000 (11:11 -0600)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 9 Aug 2022 20:30:02 +0000 (22:30 +0200)
commitc2fe646296f30b0aff6042b25f960d9a6935289c
treea8252bf36a7094a49740be11a6e6ec7a59b6ac5b
parent568e4a40e8b59aa510caff91dbb5cff05e1716f3
selftests/bpf: Fix vmtest.sh getopts optstring

Before, you could see the following errors:

  $ ./vmtest.sh -j
  ./vmtest.sh: option requires an argument -- j
  ./vmtest.sh: line 357: OPTARG: unbound variable

  $ ./vmtest.sh -z
  ./vmtest.sh: illegal option -- z
  ./vmtest.sh: line 357: OPTARG: unbound variable

Fix by adding ':' as first character of optstring. Reason is that getopts
requires ':' as the first character for OPTARG to be set in the `?` and `:`
error cases.

Note that the ':' as the first character of the optstring switches getopts
to silent mode. The desire to run in this mode seems to have been there all
along, as the script takes care of reporting errors.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Müller <deso@posteo.net>
Link: https://lore.kernel.org/bpf/0f93b56198328b6b4da7b4cf4662d05c3edb5fd2.1660064925.git.dxu@dxuuu.xyz
tools/testing/selftests/bpf/vmtest.sh