-
-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should nnn -p -
emit file details to stdout?
#1064
Comments
That's correct!
No, this output is paged,
Because |
Relevant code: https://github.com/jarun/nnn/blob/master/src/nnn.c#L4175 |
Hejsan Kevin, nice catch :) from
I'm replying via phone that is connected to my pc via VNC and my connection is spotty so i can't delve into this atm but a quick guess would be that we need to fork and then hijack the |
I still see this in the pager in a temp file:
|
@jarun Yeah. Me too. |
I don't have a solution for this, or maybe the time to explore a solution of this. Sorry. |
BTW, I understand you guys are seeing it when you redirect/pipe the output from I see the following:
So, @kevinsjoberg can you please confirm if you see the file details in the terminal when you run If yes, please share an asciicast. |
@jarun I can confirm that everything works as expected when there's no redirection. It seems like it's only a problem when stdout is redirected. |
Then do not redirect. |
I don't know if that's really a problem. |
My first problem is - the redirection was completely missing from the issue description. Why? Others explored possibilities with redirection so we figured this out. Otherwise, I wouldn't even bother to try redirection because your steps were straight and should be reproducible easily. I was going to download kitty before I saw that you mentioned you redirected. Please try to be accurate when you raise issues. |
No there is no problem. The only problem here is user is using redirection for
This is not an isolated use case. Paged output is necessary for large output on smaller screens... mediainfo output, for example. For all the reasons people prefer a pager. |
Technically,
solves this issue, but I didn't check if it causes others nor whether it's a viable solution. I always forget to clear my expandtab when working on nnn code :/ |
@jarun sorry, I should've probably shared some backstory. I'm using dte as my primary editor and it supports exec-open for opening files. See https://gitlab.com/craigbarnes/dte/-/blob/master/src/commands.c#L465 for its implementation. It will read from stdout and open the matching paths. I'm not explicitly redirecting stdout. |
Does this mean all child processes with un-suppressed output will write to stderr instead of stdout? |
In that case I would use something like
This specific diff will make all spawned process which are not silenced to redirect their |
I think we have a working design that covers this case ( I wouldn't want to do anything that universally affects all spawned cli utilities. |
For that I could just use In any case, I totally understand if this is a use case not worth supporting and if so, I'll see if I can create a shell wrapper instead. |
@jarun @annagrram quick follow up. I managed to get everything working by wrapping #!/bin/sh
set -eu
TMPFILE="$(mktemp)"
trap "rm -f '$TMPFILE'" INT QUIT TERM HUP EXIT
nnn -p "$TMPFILE" > /dev/tty
cat "$TMPFILE" Everything now works as expected for particular use case. 🙂 |
Thanks for the update! |
@jarun turns out there's actually something that can be addressed in See https://gitlab.com/craigbarnes/dte/-/issues/23#note_599738376 for details. |
I understand that you are writing a script and want to get it right... now you have to understand that I am a chip guy with a family and silly terminal quirks are as trivial as it gets to me. :) Please raise the PR or if @annagrram or @KlzXS can take a look I'm fine with it. 👍 |
@jarun absolutely. I'm a father of two myself, so I have nothing but respect for you prioritising your time. 🙂 I'm still fairly new to C, but if I manage to get something working, I'll definitely submit a pull request. 👍 |
Sure thing! I'm re-opening the issue. If we don't have anything in a week, I will add a line item with reference to the issue. |
assigning myself in case no one picks this up ill take a look at this by the end of summer... |
This relies on the output being piped, but that was what you eventually wanted, so nice idea :) |
Fixed at #1070. |
@kevinsjoberg please confirm your implementation works fine with commit 25fab4c. |
Environment details (Put
x
in the checkbox along with the information)11.3.1
0.20.3
5.1.8
-p -
nnn
masterExact steps to reproduce the issue
When providing
-p -
, my assumption was that file selection would output to stdout, but when pressingf
to get file details, this output is also outputted to stdout, which is kind of unexpected. If I instead, provide a regular file to-p
like sonnn -p output.txt
, pressingf
does not output into it.nnn -p -
f
enter
nnn -p output.txt
f
enter
The text was updated successfully, but these errors were encountered: