           "# To auto-regenerate this file when `doom reload` is run, use `doom env auto'\n"
           "# or set DOOMENV=1 in your shell environment/config.\n"
           "# ---------------------------------------------------------------------------\n\n"))
-        (let ((env-point (point)))
-          ;; temporarily unset ignored environment variables
-          (dolist (var doom-env-ignored-vars)
-            (setenv var nil))
-          (dolist (shell-command-switch doom-env-switches)
-            (message "Scraping env from '%s %s %s'"
-                     shell-file-name
-                     shell-command-switch
-                     doom-env-executable)
-            (insert (shell-command-to-string doom-env-executable))))))))
+        ;; temporarily unset ignored environment variables
+        (dolist (var doom-env-ignored-vars)
+          (setenv var nil))
+        (let ((shell-command-switch doom-env-switches))
+          (message "Scraping env from '%s %s %s'"
+                   shell-file-name
+                   shell-command-switch
+                   doom-env-executable)
+          (insert (shell-command-to-string doom-env-executable)))))))

          "# ---------------------------------------------------------------------------\n"
          "# This file was auto-generated by Doom by running:\n"
          "#\n"
          (cl-loop for switch in doom-env-switches
                   concat (format "#   %s %s %s\n"
                                  shell-file-name
                                  switch
                                  doom-env-executable))
          "#\n"
          "# It contains all environment variables scraped from your default shell\n"
          "# (excluding variables blacklisted in doom-env-ignored-vars).\n"


(defvar doom-env-switches
  (if IS-WINDOWS
      "-c"
    "-ic") ; Execute in an interactive shell
  "The `shell-command-switch'es to use on `doom-env-executable'.
This is a list of strings. Each entry is run separately and in sequence with
`doom-env-executable' to scrape envvars from your shell environment.")
