Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 592470 - sys-apps/gentoo-functions: consoletype failure aborts scripts with set -e
Summary: sys-apps/gentoo-functions: consoletype failure aborts scripts with set -e
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2016-08-30 20:43 UTC by James Le Cuirot
Modified: 2016-08-30 21:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Prevent consoletype failure from aborting scripts with set -e (0001-Prevent-consoletype-failure-from-aborting-scripts-wi.patch,791 bytes, patch)
2016-08-30 20:43 UTC, James Le Cuirot
Details | Diff
Use absolute path to consoletype as /sbin is not in user PATH (0002-Use-absolute-path-to-consoletype-as-sbin-is-not-in-u.patch,798 bytes, patch)
2016-08-30 20:46 UTC, James Le Cuirot
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Le Cuirot gentoo-dev 2016-08-30 20:43:19 UTC
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.
Comment 1 James Le Cuirot gentoo-dev 2016-08-30 20:46:50 UTC
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.
Comment 2 Mike Gilbert gentoo-dev 2016-08-30 20:51:54 UTC
(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.
Comment 3 James Le Cuirot gentoo-dev 2016-08-30 20:55:38 UTC
(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.
Comment 4 Mike Gilbert gentoo-dev 2016-08-30 21:49:04 UTC
(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.
Comment 5 James Le Cuirot gentoo-dev 2016-08-30 21:56:42 UTC
(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.