[Nix-dev] less: When assumptions ruin the world
Ertugrul Söylemez
ertesx at gmx.de
Fri Jan 2 14:49:18 CET 2015
Hi Bjørn,
> Hm, I've never thought of "automatic less" as a misfeature before. I
> didn't have anything to do with its inclusion in nix, but I remember
> when I started using git that I was pleasantly surprised by it's use
> of less, which made git more fun to work with. (If I was a nix
> developer I might have added "automatic less" myself.)
I guess that you're not the only one who likes a more interactive user
experience, which is probably why Nix got this feature in the first
place. But it assumes a workflow where interactivity is achieved
through the program in question. In my case it is achieved by my shell
and my terminal emulator and that fits the way I use Nix. In particular
I don't want Nix to enforce the invoke-pager-then-quit pattern on me,
even if I do use a pager, because that's not the way I work.
Just to give you a data point: I've always been pissed off by Git's
auto-invocation of the pager. But that's only one and a rather small
addition to my long list of reasons why I hate Git.
> So what's the best way forward? Using $NIX_PAGER first, as suggested
> by Michael Jones earlier in this thread? That should cover your use
> case, right? (_And_ preserve the current behaviour for people liking
> it "interactive"?
That sounds like a reasonable solution to me, as long as it's strictly
opt-in. In other words, you have to set NIX_PAGER to pipe through a
pager by default, otherwise it just prints to stdout. The sole fact of
using a pager on the wrong level (program-level instead of shell-level)
will make NIX_PAGER completely useless for me, even when I use a pager.
There is good reason why I insist that piping should always be done by
the shell, not by the programs you invoke.
However, I really think that a better solution is to use your shell
properly. There is absolutely no reason for Nix to do the piping, and
there is plenty of reason not to do it. Remember that programs should
only do one thing and do it well? Shells are for piping, and they do it
well. Nix is for building and managing derivations and environments,
and it does it well.
There is a very good reason for this principle. If a program does more
than what it's intended to do, then it hurts composability. That will
piss people like me off who really love the Unix philosophy, because it
fits well with my algebraic way of thinking and therefore with the
assumptions I make about my system.
Bonus: Making programs less interactive is always a win, because you
can always make an interactive frontend to a noninteractive program.
But you cannot make a noninteractive frontend to an interactive one.
Greets,
Ertugrul
More information about the nix-dev
mailing list