Skip to content

Commit bcda71d

Browse files
authored
MINOR: [R] Make update-checksums.R work on macOS out of the box (#45617)
### Rationale for this change For R release managers on macOS, the update-checksums.R script we use doesn't run because the sed command we use in that script only works on GNU sed and not BSD sed. ### What changes are included in this PR? - Makes update-checksum-R work on macOS by assuming the user has gsed available from Homebrew and using that always ### Are these changes tested? Yes ### Are there any user-facing changes? No. Authored-by: Bryce Mecum <[email protected]> Signed-off-by: Bryce Mecum <[email protected]>
1 parent a01a812 commit bcda71d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

r/tools/update-checksums.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ args <- commandArgs(TRUE)
2828
VERSION <- args[1]
2929
tools_root <- ""
3030

31+
# Use gsed on macOS and sed otherwise
32+
if (identical(unname(Sys.info()["sysname"]), "Darwin")) {
33+
SED_BIN <- "gsed"
34+
} else {
35+
SED_BIN <- "sed"
36+
}
37+
3138
if (length(args) != 1) {
3239
stop("Usage: Rscript tools/update-checksums.R <version>")
3340
}
@@ -62,7 +69,7 @@ for (path in binary_paths) {
6269
if (grepl("windows", path)) {
6370
cat(paste0("Converting ", path, " to windows style line endings\n"))
6471
# UNIX style line endings cause errors with mysys2 sha512sum
65-
sed_status <- system2("sed", args = c("-i", "s/\\\\r//", file))
72+
sed_status <- system2(SED_BIN, args = c("-i", "s/\\\\r//", file))
6673
if (sed_status != 0) {
6774
stop("Failed to remove \\r from windows checksum file. Exit code: ", sed_status)
6875
}

0 commit comments

Comments
 (0)