file.exist() and broken symlinks

Today I’ve found a problem with file.exists() for broken symlinks on OS X. Here is a simplified code example:

for (File file: files) {
  if (!file.exists()) {

  if (file.isDirectory()) {
  else {

This looks quiet fine at the first sight, but this may cause problems if the file is a broken symlink, because file.exists() returns false for a broken symlink. Hence, in the above example code, the broken symlink will not be deleted.

Launching Terminal (cmd.exe) from Java

Until now SmartGit used following command for its default Open in Terminal external tool:

cmd.exe /k start /d <path>

This did not work for paths like C:\foo, bar+=hello & world though SmartGit had logic to escape the path in this case when launching cmd.exe. Also, the Task Manager showed two running cmd.exe processes, one remaining after the window has been closed. Changing the command to

cmd.exe /c start pushd <path>

resolves both problems and the path-escaping logic also is not necessary anymore.