Summary: | sys-apps/gentoo-functions: consoletype failure aborts scripts with set -e | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | James Le Cuirot <chewi> |
Component: | Current packages | Assignee: | William Hubbs <williamh> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | base-system, floppym, sam |
Priority: | Normal | Keywords: | PATCH |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
Prevent consoletype failure from aborting scripts with set -e
Use absolute path to consoletype as /sbin is not in user PATH |
Created attachment 444482 [details, diff]
Use absolute path to consoletype as /sbin is not in user PATH
This second patch calls consoletype with an absolute PATH. This doesn't take account of EPREFIX. I don't know whether you'd prefer to call hprefixify in the ebuild or have the Makefile take care of it with sed or something.
(In reply to James Le Cuirot from comment #1) Another option would be to move consoletype to /bin; I see no reason to have it in sbin. (In reply to Mike Gilbert from comment #2) > Another option would be to move consoletype to /bin; I see no reason to have > it in sbin. That did cross my mind as well. Up to you. (In reply to James Le Cuirot from comment #0) I think this patch breaks set -e when consoletype happens to be in PATH. The exclamation mark just toggles the exit status between 0 and non-zero. (In reply to Mike Gilbert from comment #4) > > I think this patch breaks set -e when consoletype happens to be in PATH. The > exclamation mark just toggles the exit status between 0 and non-zero. Check man set, it causes the exit status to be ignored. I was going to do "|| true" but wondered if there is another way and turns out there is. I tested it in bash and dash. Resolved by: commit 1c801ce130726a81c59b96cdf4e2bef27893e0b7 Author: Kerin Millar <kfm@plushkava.net> Date: Thu Jul 28 01:57:17 2022 +0100 functions.sh: fix TTY detection The use of stdout as an argument in consoletype seems to be based on a misunderstanding. It doesn't do anything except guarantee the exit status is 0. The value is thrown away anyway. This fixes e.g. elibtoolize (from elt-patches) having no colour for its e.g. ewarn/einfo/etc because when invoked from an ebuild, it's detected as serial. Use a simpler test instead. We may want to clean up the logic in consoletype in future too (just drop lines 82-85?). Signed-off-by: Kerin Millar <kfm@plushkava.net> Signed-off-by: Sam James <sam@gentoo.org> |
Created attachment 444480 [details, diff] Prevent consoletype failure from aborting scripts with set -e The call to consoletype usually fails when run as non-root as /sbin isn't in the user PATH. The PATH issue could be fixed but any failure breaks scripts that have set -e. Prepending the call with ! counteracts this. See the first patch.