[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/45: environment: Report "command not found" from the child process.
From: |
guix-commits |
Subject: |
03/45: environment: Report "command not found" from the child process. |
Date: |
Thu, 4 Aug 2022 06:07:06 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit ae1f12018112573bf142596b78d75dbfd723d859
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Aug 4 11:13:48 2022 +0200
environment: Report "command not found" from the child process.
Fixes a bug whereby, for example:
guix shell bash -- bash -c xyz
would erroneously print:
guix shell: error: bash: command not found
simply because the parent process could not distinguish that 127 from a
"genuine" 127 used by convention for "command not found".
* guix/scripts/environment.scm (launch-environment): Before exiting,
report a "command not found" error and suggest a command name.
(validate-exit-status): Remove.
(launch-environment/fork): Remove call
(launch-environment/container)[exit/status*]: Remove.
Call 'exit/status' instead of it.
---
guix/scripts/environment.scm | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 3216235937..2493134470 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -408,7 +408,14 @@ regexps in WHITE-LIST."
(lambda ()
(apply execlp program program args))
(lambda _
- ;; Following established convention, exit with 127 upon ENOENT.
+ ;; Report the error from here because the parent process cannot
+ ;; distinguish between the conventional 127 exit code and a process
+ ;; that exited with 127 for other reasons (e.g., "sh -c xyz").
+ (report-error (G_ "~a: command not found~%") program)
+ (suggest-command-name profile command)
+
+ ;; Following established convention, exit with 127 (aka. EX_NOTFOUND)
+ ;; upon ENOENT.
(primitive-_exit 127))))))
(define (child-shell-environment shell profile manifest)
@@ -581,17 +588,6 @@ command name."
(display-hint (format #f (G_ "Did you mean '~a'?~%")
closest)))))))))
-(define (validate-exit-status profile command status)
- "When STATUS, an integer as returned by 'waitpid', is 127, raise a \"command
-not found\" error. Otherwise return STATUS."
- ;; Most likely, exit value 127 means ENOENT.
- (when (eqv? (status:exit-val status) 127)
- (report-error (G_ "~a: command not found~%")
- (first command))
- (suggest-command-name profile command)
- (exit 1))
- status)
-
(define* (launch-environment/fork command profile manifest
#:key pure? (white-list '()))
"Run COMMAND in a new process with an environment containing PROFILE, with
@@ -604,7 +600,7 @@ regexps in WHITE-LIST."
#:white-list white-list))
(pid (match (waitpid pid)
((_ . status)
- (validate-exit-status profile command status))))))
+ status)))))
(define* (launch-environment/container #:key command bash user user-mappings
profile manifest link-profile? network?
@@ -625,9 +621,6 @@ WHILE-LIST."
(and (file-exists? (file-system-mapping-source mapping))
(file-system-mapping->bind-mount mapping)))
- (define (exit/status* status)
- (exit/status (validate-exit-status profile command status)))
-
(mlet %store-monad ((reqs (inputs->requisites
(list (direct-store-path bash) profile))))
(return
@@ -684,7 +677,7 @@ WHILE-LIST."
'())
(map file-system-mapping->bind-mount
mappings))))
- (exit/status*
+ (exit/status
(call-with-container file-systems
(lambda ()
;; Setup global shell.
- 45/45: gnu: Add python-h5netcdf., (continued)
- 45/45: gnu: Add python-h5netcdf., guix-commits, 2022/08/04
- 31/45: gnu: Add ruby-rdf-vocab., guix-commits, 2022/08/04
- 08/45: gnu: libomp-13: Reference llvm-13 version string., guix-commits, 2022/08/04
- 21/45: gnu: Add libomp-6., guix-commits, 2022/08/04
- 38/45: gnu: Add ruby-anystyle., guix-commits, 2022/08/04
- 01/45: guix build: Print hints when -s or --target is passed an invalid string., guix-commits, 2022/08/04
- 32/45: gnu: Add ruby-bibtex-ruby., guix-commits, 2022/08/04
- 28/45: gnu: Add ruby-latex-decode., guix-commits, 2022/08/04
- 04/45: gnu: Add barony., guix-commits, 2022/08/04
- 17/45: gnu: Add libomp-8., guix-commits, 2022/08/04
- 03/45: environment: Report "command not found" from the child process.,
guix-commits <=
- 27/45: gnu: Add ruby-ritex., guix-commits, 2022/08/04
- 42/45: gnu: anystyle: Add tests for dictionary adapters., guix-commits, 2022/08/04
- 30/45: gnu: Add ruby-rdf., guix-commits, 2022/08/04
- 22/45: gnu: clang-toolchain-6: Use libomp-6., guix-commits, 2022/08/04
- 14/45: gnu: clang-toolchain-10: Use libomp-10., guix-commits, 2022/08/04
- 44/45: gnu: python-netcdf4: Update to 1.6.0, guix-commits, 2022/08/04