public static function escapeShellArg($arg, $escapeFor = NULL) {
    $escaped = \Symfony\Component\Process\ProcessUtils::escapeArgument($arg);

    return Preg::replace($escaped, '~(?<!\\\\)\\\\"$~', '\\\\\\"');
  }