aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-03-02 23:13:58 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-03-04 21:43:10 +0200
commit6f637948596bc7aff9fb0ac1cc88d910512bb488 (patch)
tree95613a4dc6f27fcbf592609957745cbafbbf53ca
parent4469d33f4921432e67b98151eeb6b4c2a17d648e (diff)
Don't execute empty string as shell command for non-git sub-projects
projectile-get-sub-projects-command returned "" for non-git VCSes, which passed the stringp guard in projectile-files-via-ext-command and spawned a useless shell process. Return nil instead, and also make the guard defensive against empty strings to match the docstring's contract.
-rw-r--r--projectile.el4
-rw-r--r--test/projectile-test.el4
2 files changed, 4 insertions, 4 deletions
diff --git a/projectile.el b/projectile.el
index cc99ea4..6c833af 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1617,7 +1617,7 @@ Currently that's supported just for Git (sub-projects being Git
sub-modules there)."
(pcase vcs
('git projectile-git-submodule-command)
- (_ "")))
+ (_ nil)))
(defun projectile-get-ext-ignored-command (vcs)
"Determine which external command to invoke based on the project's VCS."
@@ -1703,7 +1703,7 @@ If `command' is nil or an empty string, return nil.
This allows commands to be disabled.
Only text sent to standard output is taken into account."
- (when (stringp command)
+ (when (and (stringp command) (not (string-empty-p command)))
(let ((default-directory root))
(with-temp-buffer
(shell-command command t "*projectile-files-errors*")
diff --git a/test/projectile-test.el b/test/projectile-test.el
index e26ed66..39f577d 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -638,8 +638,8 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(describe "projectile-get-sub-projects-command"
(it "gets sub projects command for git"
(expect (string-prefix-p "git" (projectile-get-sub-projects-command 'git)) :to-be-truthy))
- (it "returns empty when vcs is not supported"
- (expect (string-empty-p (projectile-get-sub-projects-command 'none)) :to-be-truthy)))
+ (it "returns nil when vcs is not supported"
+ (expect (projectile-get-sub-projects-command 'none) :to-be nil)))
(describe "projectile-files-via-ext-command"
(it "returns nil when command is nil or empty or fails"