Latest interactive-replace... does nothing?

79 views
Skip to first unread message

Weijia Cheng

unread,
Jun 24, 2021, 10:47:01 PM6/24/21
to Standard Ebooks
Hi, I have been having a very peculiar problem with the latest version of the toolset. When I run interactive-replace with patterns that should have a match, it appears that the command immediately ends silently without opening any interactive terminal UI or displaying any output. Here is a pastebin that shows what I am talking about (also, it seem the program is exiting without any errors):

I am very unsure of what the problem might be here. I have tried uninstalling and reinstalling the standardebooks package but that did nothing for me. Is it possible that I am missing a dependency somewhere? My computer is running Ubuntu in case that's relevant. The old interactive-sr worked perfectly fine for me so this feels like a bit of a regression.

Has anyone seen this before or have any idea of what might be happening?

Vince

unread,
Jun 24, 2021, 11:52:43 PM6/24/21
to Standard Ebooks
Works here, but I’m on OSX Big Sur. The only thing it depends on that I can see is curses, and I would imagine that comes standard on Linux. Sorry, no idea what the problem could be. However, note that you didn’t grep for the same search string that you passed to the command; just searching for “every one” isn’t sufficient, you have to do the whole thing to know you have something it should have found.

Weijia Cheng

unread,
Jun 25, 2021, 12:02:16 AM6/25/21
to Standard Ebooks
Fair, that was supposed to be a "realistic" example but even a command like this does nothing:

wcheng@pop-os:~/git/thomas-a-kempis_the-imitation-of-christ_william-benham$ se interactive-replace "a" "b" src/epub/text/*
wcheng@pop-os:~/git/thomas-a-kempis_the-imitation-of-christ_william-benham$

Vince

unread,
Jun 25, 2021, 12:19:55 AM6/25/21
to Standard Ebooks
So, in your grep, you grep the current directory. Which would imply you’re already in src/epub/text. But when you call interactive-replace, you’re still passing src/epub/text. Which is looking for src/epub/text underneath the current directory, i.e. src/epub/text/src/epub/text.

Weijia Cheng

unread,
Jun 25, 2021, 12:27:54 AM6/25/21
to Standard Ebooks
Ah, but if you look at the pastebin, you can see that my working directory was the repository's root when I executed the interactive-replace. It was a git grep so I was not grepping the current directory, but the entire repository. I don't think that would explain the problem.

Alex Cabal

unread,
Jun 25, 2021, 1:53:16 AM6/25/21
to standar...@googlegroups.com
Copying and pasting that command into a random repo seemed to work fine
for me and I'm also on Ubuntu. Maybe you can step through the source to
see where it's going wrong.

On 6/24/21 11:02 PM, Weijia Cheng wrote:
> Fair, that was supposed to be a "realistic" example but even a command
> like this does nothing:
>
> wcheng@pop-os:~/git/thomas-a-kempis_the-imitation-of-christ_william-benham$
> se interactive-replace "a" "b" src/epub/text/*
> wcheng@pop-os:~/git/thomas-a-kempis_the-imitation-of-christ_william-benham$
>
> On Thursday, June 24, 2021 at 8:52:43 PM UTC-7 Vince wrote:
>
> Works here, but I’m on OSX Big Sur. The only thing it depends on
> that I can see is curses, and I would imagine that comes standard on
> Linux. Sorry, no idea what the problem could be. However, note that
> you didn’t grep for the same search string that you passed to the
> command; just searching for “every one” isn’t sufficient, you have
> to do the whole thing to know you have something it should have found.
>
> > On Jun 24, 2021, at 9:47 PM, Weijia Cheng <weijia...@gmail.com>
> wrote:
> >
> > Hi, I have been having a very peculiar problem with the latest
> version of the toolset. When I run interactive-replace with patterns
> that should have a match, it appears that the command immediately
> ends silently without opening any interactive terminal UI or
> displaying any output. Here is a pastebin that shows what I am
> talking about (also, it seem the program is exiting without any
> errors):
> >
> > https://pastebin.com/KiKSCP1c <https://pastebin.com/KiKSCP1c>
> >
> > I am very unsure of what the problem might be here. I have tried
> uninstalling and reinstalling the standardebooks package but that
> did nothing for me. Is it possible that I am missing a dependency
> somewhere? My computer is running Ubuntu in case that's relevant.
> The old interactive-sr worked perfectly fine for me so this feels
> like a bit of a regression.
> >
> > Has anyone seen this before or have any idea of what might be
> happening?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Standard Ebooks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to standardebook...@googlegroups.com
> <mailto:standardebook...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/standardebooks/a50c1aa4-1815-4b10-9339-da2954fc9609n%40googlegroups.com
> <https://groups.google.com/d/msgid/standardebooks/a50c1aa4-1815-4b10-9339-da2954fc9609n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Weijia Cheng

unread,
Jun 25, 2021, 2:07:55 AM6/25/21
to Standard Ebooks
Ok, I guess I'll set up a debugging environment and see if I can figure out something myself when I have some free time.

Weijia Cheng

unread,
Jun 25, 2021, 11:31:52 AM6/25/21
to Standard Ebooks
Ok, now this is fascinating. I created a debugging branch of tools, which you can see here: https://github.com/weijia-cheng/tools/blob/debugging/se/commands/interactive_replace.py

When I run the command on the debugging branch, I get this output. Notice that "debugging line 4" (the one after "Disable the blinking cursor") is missing! https://pastebin.com/2mMUHYjW

In fact, when I delete the "curses.curs_set(False)" line, the UI appears. So it seems it must have something to do with that.I will keep investigating and see if I can figure this issue out.

Weijia Cheng

unread,
Jun 25, 2021, 11:36:06 AM6/25/21
to Standard Ebooks
Aha! I made the catch block print out the exception. Here's a new pastebin, showing that curs_set returned ERR: https://pastebin.com/35q1Ryne


The Python docs says that it will raise an exception if the terminal does not support the visibility requested. I think we need to make interactive-sr more tolerant of this difference between terminals.

Weijia Cheng

unread,
Jun 25, 2021, 11:47:56 AM6/25/21
to Standard Ebooks
Alex, here is a simple PR that resolves the issue for me: https://github.com/standardebooks/tools/pull/451
Reply all
Reply to author
Forward
0 new messages