Commit a7be0ab1 authored by Daniel Xu's avatar Daniel Xu Committed by Daniel Borkmann

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: default avatarDaniel Xu <dxu@dxuuu.xyz>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarDaniel Müller <deso@posteo.net>
Link: https://lore.kernel.org/bpf/0f93b56198328b6b4da7b4cf4662d05c3edb5fd2.1660064925.git.dxu@dxuuu.xyz
parent d020b236
...@@ -333,7 +333,7 @@ main() ...@@ -333,7 +333,7 @@ main()
local exit_command="poweroff -f" local exit_command="poweroff -f"
local debug_shell="no" local debug_shell="no"
while getopts 'hskid:j:' opt; do while getopts ':hskid:j:' opt; do
case ${opt} in case ${opt} in
i) i)
update_image="yes" update_image="yes"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment