Skip to content

Commit

Permalink
fix #427: use shell() to execute the command if its path would be sho…
Browse files Browse the repository at this point in the history
…rtened by system2() on Windows
  • Loading branch information
yihui committed Oct 30, 2023
1 parent 3495cb8 commit e2ee101
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ read_lines = function(...) {
x[!validEnc(x)] = ''
x
}

# for some reason, some TeX Live utilities refuse to work if they are called by
# their short paths (#427), in which case we switch to shell()
if (xfun::is_windows()) system2 = function(command, args, ...) {
if (length(list(...)) > 0 || !is_short(command)) {
base::system2(command, args, ...)
} else shell(paste(c(command, args), collapse = ' '))
}

# test if a path would be shortened on Windows
is_short = function(x) {
x = Sys.which(x)
(x != '') && (normalizePath(x) != shortPathName(x))
}

0 comments on commit e2ee101

Please sign in to comment.