Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple command line options ignored #388

Open
MASHtm opened this issue Apr 13, 2021 · 2 comments
Open

multiple command line options ignored #388

MASHtm opened this issue Apr 13, 2021 · 2 comments

Comments

@MASHtm
Copy link

MASHtm commented Apr 13, 2021

If multiple command line options are used only the first one gets parsed. eg. "-c configpath --force". This is caused by misplaced "break" commands

# Generic command line options
while true ; do
  case "${1}" in
    -c|--config) xshok_check_s2 "${2}"; custom_config="${2}"; shift 2; break ;;
    -F|--force) force_updates="yes"; shift 1; break ;;
    -v|--verbose) force_verbose="yes"; shift 1; break ;;
    -s|--silence) force_verbose="no"; shift 1; break ;;
    *) break ;;
  esac
done

I think it would be better to use the bash builtin getopts like

while getopts ":c:Fvs" opt; do
  case ${opt} in
.....
  esac
done
shift $((OPTIND -1))
@MASHtm
Copy link
Author

MASHtm commented Apr 13, 2021

Since getopts doesn't support long opts I used:

--- clamav-unofficial-sigs.sh	(revision 5032)
+++ clamav-unofficial-sigs.sh	(working copy)
@@ -1710,14 +1710,15 @@
 fi
 
 # Generic command line options
-while true ; do
+while :; do
   case "${1}" in
-    -c|--config) xshok_check_s2 "${2}"; custom_config="${2}"; shift 2; break ;;
-    -F|--force) force_updates="yes"; shift 1; break ;;
-    -v|--verbose) force_verbose="yes"; shift 1; break ;;
-    -s|--silence) force_verbose="no"; shift 1; break ;;
+    -c|--config) xshok_check_s2 "${2}"; custom_config="${2}"; shift ;;
+    -F|--force) force_updates="yes" ;;
+    -v|--verbose) force_verbose="yes" ;;
+    -s|--silence) force_verbose="no" ;;
     *) break ;;
   esac
+  shift
 done
 
 # Set the verbosity

@perplexityjeff
Copy link
Contributor

perplexityjeff commented Apr 14, 2021

Would this fix work on all versions that the script supports? If so then feel free to create a pull request with these changes. Even if not final this creates discussion hopefully to fix this.

@extremeshok extremeshok added this to the 7.2.6 milestone Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants