Avoid recursive cargo calls when doing cargo clif instead of cargo-clif

Fixes #1383
diff --git a/scripts/cargo-clif.rs b/scripts/cargo-clif.rs
index 99b97be..f73b201 100644
--- a/scripts/cargo-clif.rs
+++ b/scripts/cargo-clif.rs
@@ -40,14 +40,22 @@
         "cargo"
     };
 
-    let args: Vec<_> = match env::args().nth(1).as_deref() {
+    let mut args = env::args().skip(1).collect::<Vec<_>>();
+    if args.get(0).map(|arg| &**arg) == Some("clif") {
+        // Avoid infinite recursion when invoking `cargo-clif` as cargo subcommand using
+        // `cargo clif`.
+        args.remove(0);
+    }
+
+    let args: Vec<_> = match args.get(0).map(|arg| &**arg) {
         Some("jit") => {
             env::set_var(
                 "RUSTFLAGS",
                 env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
             );
+            args.remove(0);
             IntoIterator::into_iter(["rustc".to_string()])
-                .chain(env::args().skip(2))
+                .chain(args)
                 .chain([
                     "--".to_string(),
                     "-Zunstable-options".to_string(),
@@ -60,8 +68,9 @@
                 "RUSTFLAGS",
                 env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
             );
+            args.remove(0);
             IntoIterator::into_iter(["rustc".to_string()])
-                .chain(env::args().skip(2))
+                .chain(args)
                 .chain([
                     "--".to_string(),
                     "-Zunstable-options".to_string(),
@@ -69,7 +78,7 @@
                 ])
                 .collect()
         }
-        _ => env::args().skip(1).collect(),
+        _ => args,
     };
 
     #[cfg(unix)]