Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 956051 - Add eindent, eoutdent output commands
Summary: Add eindent, eoutdent output commands
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Package Manager Specification
URL:
Whiteboard: distant-future-eapi
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2025-05-17 08:39 UTC by Sam James
Modified: 2025-05-27 07:44 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-17 08:39:49 UTC
sys-apps/gentoo-functions supports eindent and eoutdent to modify the behaviour of einfo and friends ("Output commands" listed in "12.3.5 Output commands").

eindent increases the indentation level of subsequent commands, while eoutdent decrements it.

The latest usecase that came up was possibly in Python eclasses where phases get repeated for each Python implementation, like:
```
* python3_12: running distutils-r1_run_phase python_install
 * Optimize Python modules in /usr/lib/python3.12/site-packages
* python3_13: running distutils-r1_run_phase python_install
 * Optimize Python modules in /usr/lib/python3.13/site-packages
* python3_14: running distutils-r1_run_phase python_install
 * Optimize Python modules in /usr/lib/python3.14/site-packages
```
instead of the current:
```
* python3_12: running distutils-r1_run_phase python_install
* Optimize Python modules in /usr/lib/python3.12/site-packages
* python3_13: running distutils-r1_run_phase python_install
* Optimize Python modules in /usr/lib/python3.13/site-packages
* python3_14: running distutils-r1_run_phase python_install
* Optimize Python modules in /usr/lib/python3.14/site-packages
```

I think it has some natural usecases in anything multilib/many impl but also functions which iterate by depth or similar.

Unfortunately, it's not really possible to testdrive this via an eclass because of how the other functions are implemented.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2025-05-17 12:46:43 UTC
I don't really have a strong opinion on this, but one argument for implementing it would be consistency with how e* functions are used elsewhere.
Comment 2 Ulrich Müller gentoo-dev 2025-05-17 12:54:57 UTC
We have done without this for a quarter century.

So unless someone convinces me that this is in a category more important than "nice to have", I'd rather postpone it to EAPI 10.
Comment 3 Ulrich Müller gentoo-dev 2025-05-24 07:23:14 UTC
Unfortunately, gentoo-functions and OpenRC have different APIs:

In sys-apps/gentoo-functions (as of version 1.7.3) these functions accept an optional argument specifying the indentation step. If no argument is specified, or if it is <= 0, a default of 2 is used.

sys-apps/openrc (as of version 0.62.2) uses a fixed value of 2. It also does this:

	: $(( EINFO_INDENT = ${EINFO_INDENT:-0} + 2 ))
	[ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40

Which is flawed: If the limit is hit, then the next eoutdent will immediately reduce indentation starting from 40, i.e. it won't align with its corresponding eindent. Looking at the implementation of _eindent() in libeinfo.c, it looks like the limit isn't even needed, because _eindent does its own limitation of the width.
Comment 4 Ulrich Müller gentoo-dev 2025-05-26 06:58:45 UTC
(In reply to Sam James from comment #0)
> The latest usecase that came up was possibly in Python eclasses where phases
> get repeated for each Python implementation, like:
> ```
> * python3_12: running distutils-r1_run_phase python_install
>  * Optimize Python modules in /usr/lib/python3.12/site-packages
> * python3_13: running distutils-r1_run_phase python_install
>  * Optimize Python modules in /usr/lib/python3.13/site-packages
> * python3_14: running distutils-r1_run_phase python_install
>  * Optimize Python modules in /usr/lib/python3.14/site-packages
> ```

This is not how it is implemented in gentoo-functions and OpenRC. For both, output looks like this:

* python3_12: running distutils-r1_run_phase python_install
*   Optimize Python modules in /usr/lib/python3.12/site-packages
* python3_13: running distutils-r1_run_phase python_install
*   Optimize Python modules in /usr/lib/python3.13/site-packages
* python3_14: running distutils-r1_run_phase python_install
*   Optimize Python modules in /usr/lib/python3.14/site-packages

That is, indentation is by 2 chars and starts after the asterisk.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-27 06:28:32 UTC
(In reply to Ulrich Müller from comment #4)
> 
> This is not how it is implemented in gentoo-functions and OpenRC. For both,
> output looks like this:
> 
> * python3_12: running distutils-r1_run_phase python_install
> *   Optimize Python modules in /usr/lib/python3.12/site-packages
> [...]
> That is, indentation is by 2 chars and starts after the asterisk.

I suppose I prefer that, I was just going off memory :)
Comment 6 Ulrich Müller gentoo-dev 2025-05-27 07:44:09 UTC
(In reply to Ulrich Müller from comment #3)
> sys-apps/openrc does this:
> 
> 	: $(( EINFO_INDENT = ${EINFO_INDENT:-0} + 2 ))
> 	[ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40
> 
> Which is flawed: If the limit is hit, then the next eoutdent will
> immediately reduce indentation starting from 40, i.e. it won't align with
> its corresponding eindent.

Fixed:
https://github.com/OpenRC/openrc/commit/4fdb883a3dc42fd9f76a3e19db66313fae9adb19