larsks's answer uses:
git submodule foreach '[ "$path" = "Libraries/JSONKit" ]
But it should now (2020) be
git submodule foreach '[ "$sm_path" = "Libraries/JSONKit" ]
With Git 2.26 (Q1 2020), The bulk of "git submodule foreach " has been rewritten in C, and its documentation evolves.
See commit fc1b924 (10 May 2018), and commit b6f7ac8, commit f0fd0dc, commit c033a2f (09 May 2018) by Prathamesh Chavan (pratham-pc).
(Merged by Junio C Hamano -- gitster -- in commit ea27893, 25 Jun 2018)
submodule foreach: document '$sm_path' instead of '$path'
As using a variable '$path' may be harmful to users due to capitalization issues, see 64394e3ae9 ("git submodule.sh: Don't use $path variable in eval_gettext string", 2012-04-17, Git v1.7.11-rc0 -- merge listed in batch #4).
Adjust the documentation to advocate for using $sm_path, which contains the same value.
We still make the 'path' variable available, and document it as a deprecated synonym of 'sm_path'.
Discussed-with: Ramsay Jones
The Documentation/git-submodule#foreach now includes:
foreach [--recursive] <command>:
Evaluates an arbitrary shell command in each checked out submodule.
The command has access to the variables $name, $sm_path, $sha1 and $toplevel:
$name is the name of the relevant submodule section in .gitmodules.
$sm_path is the path of the submodule as recorded in the immediate superproject,
$sha1 is the commit as recorded in the immediate superproject, and
$toplevel is the absolute path to the top-level of the immediate superproject.
Note that to avoid conflicts with '$PATH' on Windows, the '$path' variable is now a deprecated synonym of '$sm_path' variable.