Skip to content

Commit

Permalink
selftests/bpf: Fix vmtest.sh getopts optstring
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Daniel Xu authored and Daniel Borkmann committed Aug 9, 2022
1 parent d020b23 commit a7be0ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/vmtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ main()
local exit_command="poweroff -f"
local debug_shell="no"

while getopts 'hskid:j:' opt; do
while getopts ':hskid:j:' opt; do
case ${opt} in
i)
update_image="yes"
Expand Down

0 comments on commit a7be0ab

Please sign in to comment.