Skip to content

Commit 46d5e95

Browse files
committed
Make null device global for cross-platform compatibility
1 parent e277b28 commit 46d5e95

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

codespaces.el

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ When this is nil, the default of '/workspaces/<repo-name>' is used."
5353
:group 'codespaces
5454
:type 'string)
5555

56+
57+
(defconst codespaces--null-device
58+
(if (eq system-type 'windows-nt) "NUL" "/dev/null")
59+
"The null device used for suppressing output, specific to the operating system.")
60+
5661
(defvar codespaces--validated nil
5762
"Whether the gh CLI has been validated for codespaces access.")
5863

@@ -70,9 +75,7 @@ This check is performed lazily on first use rather than at setup time."
7075
(let ((status
7176
(let ((inhibit-read-only t))
7277
(shell-command
73-
(if (eq system-type 'windows-nt)
74-
"gh codespace list 1>NUL"
75-
"gh codespace list 1>/dev/null")
78+
(format "gh codespace list 1>%s" codespaces--null-device)
7679
nil "*codespaces-output*"))))
7780
(unless (zerop status)
7881
(user-error
@@ -228,9 +231,8 @@ allowing for faster startup. Validation happens lazily on first use."
228231

229232
(defun codespaces--get-default-branch (repo)
230233
"Return the default branch for REPO or signal an error if not found."
231-
(let* ((null-device (if (eq system-type 'windows-nt) "NUL" "/dev/null"))
232-
(command (format "gh repo view %s --json defaultBranchRef -q .defaultBranchRef.name 2>%s"
233-
repo null-device))
234+
(let* ((command (format "gh repo view %s --json defaultBranchRef -q .defaultBranchRef.name 2>%s"
235+
repo codespaces--null-device))
234236
(branch (shell-command-to-string command)))
235237
(if (string-empty-p branch)
236238
(user-error "Error getting default branch. Likely, no repository exists or it's inaccessible")

0 commit comments

Comments
 (0)