Nnn: Hangs indefinitely when `nnn` used in wrapper script

Created on 17 Oct 2020  路  7Comments  路  Source: jarun/nnn

Environment details (Put x in the checkbox along with the information)

[x] Operating System: Ubuntu 20.04 LTS
[x] Desktop Environment: bspwm
[x] Terminal Emulator: st/kitty
[x] Shell: zsh,bash
[x] Custom desktop opener (if applicable): nwrap
[x] Program options used: none
[x] Configuration options set: export NNN_OPTS="cCdEfHorQSx"
[x] Issue exists on nnn master

Exact steps to reproduce the issue

Create an exectuable script called nwrap with the following

#!/usr/bin/env sh

nnn "$@"

And then try executing this script in the terminal or otherwise (I have it on my PATH). It just hangs indefinitely.
This issue just happened with the latest master. If I put an exec in front of nnn ..,
then it works. But I'd like to use a bash function, that does some setup options for ex like

n() {
  export LC_COLLATE="C"
  export GUI=1
  # Block nesting of nnn in subshells
  if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ] && [ ! -n "$VIMRUNTIME" ]; then
    echo "nnn is already running"
    return
  fi

  # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
  # To cd on quit only on ^G, remove the "export" as in:
  #     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
  # NOTE: NNN_TMPFILE is fixed, should not be modified
  export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

  nnn "$@"

  if [ -f "$NNN_TMPFILE" ]; then
    . "$NNN_TMPFILE"
    rm -f "$NNN_TMPFILE" >/dev/null
  fi
}

But this is irrelevant for now. The simple script above should work without having to use
an exec clause.

bug

Most helpful comment

Also, many thanks for reporting the issue. The patch could have made the next release a huge blunder.

@Kratacoa just FYI, we had to revert the patch. As I could see between kitty and xfce4-terminal, there is no single absolute way to have the behaviour you were looking for. I may spend some time on it if I ever get the chance but there's no guarantee as I do not use kitty (or xfce4-terminal with this use case). Anyone else is more than welcome to take a look,

All 7 comments

I get the feeling that nnn is resolving to some other function recursively in your environment. Meaning nwrap is expanding nnn to something else other than the nnn executable recursively...

Ah okay, possibly. I will look into it more to see what is going on!

So I entered the full path to the executable as

$HOME/.local/bin/nnn ...

and it still does not work.
Seems really weird. And this did not happen until yesterday.
It was just after I pulled from master today

I think we made a bad fix. Please test master and confirm.

Bingo, fixed! Thanks for the quick response!
This program is awesome btw!

Also, many thanks for reporting the issue. The patch could have made the next release a huge blunder.

@Kratacoa just FYI, we had to revert the patch. As I could see between kitty and xfce4-terminal, there is no single absolute way to have the behaviour you were looking for. I may spend some time on it if I ever get the chance but there's no guarantee as I do not use kitty (or xfce4-terminal with this use case). Anyone else is more than welcome to take a look,

@amanjitsk

This program is awesome btw!

Thanks to a highly capable and responsive team who understand the world doesn't need another bloatware... and thanks to awesome users like you who love a niche program for what it wants to be and remain. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexx-oo picture alexx-oo  路  3Comments

tim77 picture tim77  路  9Comments

snide picture snide  路  6Comments

kuntau picture kuntau  路  3Comments

Wuzado picture Wuzado  路  9Comments