2,262 questions
3
votes
3
answers
228
views
Performance issues with reading lines from *standard-input*
I need to process 100 Gigabytes of logs in a weird format, then do some analysis on the results.
Initial parts of parsing and CLI done, tried on some test data with 1 GB and it took around a minute. I ...
1
vote
0
answers
88
views
Is there a way to clear a line-wrapped text in a GNU Readline prompt?
I have been writing a simple REPL application in C. One of the required features was syntax highlighting so I wrote my own rl_redisplay function that allows me to highlight the test using ANSI escape ...
1
vote
1
answer
132
views
php's readline() method adding weird line breaks when executed via shell?
So I have this really weird issue where I have the following dummy.php script:
<?php
declare(strict_types=1);
$prompt = "Hello there!".
PHP_EOL . "What do you want to know?"...
0
votes
0
answers
90
views
How to stop last prompt line from flickering while printing lines above it in a loop?
I'm working with Node.js (ESM .mjs file) on macOS terminal.
My printing logic is:
Start printing from the current top line in the terminal downward.
Continuously add new lines (Hello, world! ) in ...
0
votes
1
answer
75
views
How to stop emitting keypress events after calling `readline.emitKeypressEvents` in Node.js [duplicate]
I want to asynchronously process keyboard events in a Node.js application. It was recommended to me to use readline.emitKeypressEvents which leads to code like this:
import readline from "node:...
0
votes
1
answer
154
views
Python interpreter doesn't honour .inputrc readline settings when run from a venv
My .inputrc file, which simply contains set editing-mode vi, means that when I use Bash and some other interpretive environments, I can use Vi editor keys. This also works when I run the system Python ...
0
votes
3
answers
95
views
Using Vim macros on the command line
I am using Vim bindings in bash (set -o vi) and I wanted to know if it is possible to use and save Vim macros on the command line. For instance, I would like to save a macro like this:
let @q = "...
1
vote
3
answers
145
views
Huge time difference when reading a file inside class
Any suggestions where this huge time difference results from when reading the same large text file by the same loop from inside a class in Python.
import timeit
fn = "some-large-file.txt"
...
0
votes
3
answers
131
views
Is this the correct way to move to the beginning of each line in a text file using seek()?
from sys import argv
script, input_file = argv
hello = open(input_file)
read1 = hello.readline()
print("Line1: ", read1, end = "")
line1 = len(read1) + 1
print(line1)
read2 = ...
3
votes
2
answers
201
views
How to detect stdin input in a cancel-safe way in Rust async?
Problem
I'm working with asynchronous code in Rust and trying to handle user input from stdin in a cancel-safe manner. My goal is to be able to detect when a user presses a key (or hits enter) to ...
1
vote
0
answers
116
views
gdb backspace deletes whole line?
I just hate it so much when small things that were working since forever suddenly break.
I use MINGW64 bash in Windows Terminal in Windows 10. When I run gdb-multiarch, inside it, suddenly Backspace ...
2
votes
2
answers
133
views
Linenoise C api - any way to preload the buffer to set a default line
I'm using linenoise with a c command line style program. The standard way of using linenoise is to do a simple
char* line;
line = linenoise("prompt: ");
// Use the line in the app
free(...
2
votes
1
answer
101
views
Can't get GNU readline with bash to use STDOUT/FD1 as rl_outstream
I am writing a Go wrapper that does various things and then executes an interactive bash shell. I would like to usurp FD2 of this child process with my own thing that is fed in from the Go wrapper. ...
1
vote
1
answer
170
views
Force readline to exit with signals
I am trying to get readline to exit when I press ctrl-c. I thought I could do this with rl_done but it is not working.
Upon pressing ctrl-c I am getting these debug statements:
start readline
setting ...
1
vote
0
answers
27
views
Why puppeteer blocks callbacks from execution?
This code as it is opens the browser and read a txt file line by line:
line 1
line 2
line 3
Stream closed
The thing I don't understand is why placing const browser = await puppeteer....
0
votes
0
answers
93
views
libreadline.so.8: undefined symbol: UP in ubuntu 20 lts
same problem as for libreadline.so.7 in fedora. It seems that readline configure is catastrophic assuming that readline.so is already present in /usr/lib
0
votes
1
answer
74
views
clang: error: no such file or directory: '–lreadline'
I am migrating a working application on a Raspberry Pi to the latest OS Bookworm.
On make, I get the following error:
make
clang++ -lpthread -L/usr/local/lib –lreadline -lcurl -lpigpio -o build/...
0
votes
1
answer
72
views
R markdown and readline()
I am attempting to create a vignette in R Markdown for a package that I have created. Within one of these R functions, it has a readline() requiring user input to confirm continuing an analysis based ...
2
votes
0
answers
68
views
process.stdin is not recognized as ReadableStream when using readline.createInterface
I've got a strange issue with TypeScript when trying to use the readline to create an interface reading the console window. From what I can tell, process.stdin returns a ReadStream whilst ...
2
votes
1
answer
119
views
How to detect the Enter key when pasting multi-line text (containing `\r`)?
While developing a line editor in C++, I'm using getch() to capture each key input, and see \r(13 in ASCII) as the Enter key. However, when pasting text that contains multiple lines, the program ...
0
votes
1
answer
74
views
Scanner.readLine() with custom line delimeter
I have a string that needs to be read using the Scanner class from the beginning to the \n character. The problem is that the source stream in my case may contain the character \u2028. I know that the ...
1
vote
1
answer
139
views
Is it possible to modify the entire line and display autocompletion suggestions in a single go in bash?
Bash provides facilities to modify an entire line and change the position of the cursor with commands bound to bind -x through READLINE_LINE and READLINE_POINT variables:
$ cat test.sh
#!/bin/bash
...
2
votes
2
answers
96
views
How can I properly reprint a readline prompt on SIGINT?
I have the following signal handler established:
void sig_handler(int sig)
{
if (sig == SIGINT)
{
printf("\n");
rl_on_new_line();
rl_replace_line("&...
0
votes
1
answer
46
views
Memcache SET command does not work on localhost but from remote machine
I developed a basic memcache get and set implementation in c#.
When i run a test, everything works as expected, when the test is run on another machine than the memcache server.
When i run the same ...
1
vote
0
answers
97
views
Is there a way in python's readline module to bind a key to a custom function?
I'm using the python readline module (and using the input() function, which readline modifies). Everything is working, but I would like to add a feature to call a custom python function when a ...
0
votes
1
answer
601
views
Renci SSH.NET hangs on simple command and response
Using Renci SSH.NET, I am trying to send a simple command to an ethernet switch over ssh, and then to read the response back from the switch. I can connect to the switch but it just hangs when I call ...
0
votes
0
answers
45
views
Why isn't my R script pausing when I ask for a prompt?
I'm writing a script that asks for multiple user inputs using the command:
readline(prompt = "Question here")
My first attempt at the beginning of the script works correctly. I'm asking for ...
0
votes
0
answers
121
views
How can I pass input to an R script being run with nohup?
I am currently running R code on a server in the background with nohup in the following way:
nohup R --no-save < Rscriptname.R &> out &
I need to make some small changes to the script ...
1
vote
1
answer
65
views
How do I catch return characters when using character-at-a-time BASH builtin read with if or a case statement?
I stumbled across what should be something simple that's turned out to be a brain-teaser. As a not fully accomplished BASH programmer, I naively thought I could read in characters from an interactive ...
-1
votes
1
answer
119
views
Live Data from a Scale
I’m working on a project where I need to log real-time data from a weigh scale into an Excel sheet. The catch is that the data should only be logged when I click a specific cell in the Excel sheet. ...
6
votes
2
answers
2k
views
Read a single line user input with in Bun.js
Bun.js has a nice native API to read periodical user input:
const prompt = "Type something: ";
process.stdout.write(prompt);
for await (const line of console) {
console.log(`You typed: ${...
0
votes
0
answers
28
views
Trying to echo line variable along with another variable inside a while read loop
Am trying to echo a line variable along with another variable like below
while read -r line;do
id1=$(echo "$line"|grep...)
id2=`grep "$id1"...."
echo "$line" , "...
0
votes
2
answers
70
views
Having an asynchronous issue with my JavaScript code when using a timeout with Node.js
So the purpose of the code is to import JSON questions and read them to the user in the terminal. The user gets 5 seconds to answer the question until the next question is displayed. The issue I am ...
2
votes
1
answer
881
views
How can I read more than 4096 bytes from stdin, copy-pasted to a terminal on Linux?
I have this code:
import sys
binfile = "data.hex"
print("Paste ascii encoded data.")
line = sys.stdin.readline()
b = bytes.fromhex(line)
with open(binfile, "wb") as fp:...
0
votes
1
answer
119
views
Edit the final part of large(1.5gb) text file in NodeJS
My tool appends little json blocks with comma at their end into a txt file which initially has [ as the first character, in order to create a whole JSON format text file, like below,
{data: text1},
...
1
vote
4
answers
179
views
text file -- how to sort adjacent lines that have the same level of indentation
UPDATE: The root problem has been solved by fixing a number of Sequelize migrations that always run before mysqldump is called, as discussed in the comments that are below the article that is linked ...
0
votes
1
answer
59
views
Why do my Java server tests pass when I add a System.out.println(in.readLine()) statement before the tests, but fail without that statement?
I'm working on implementing a server in Java to handle a multiplayer Minesweeper game. In trying to test my server to ensure that it responds correctly to legal client requests, I am finding that the ...
1
vote
0
answers
112
views
How can I get rid of seeing escape characters in Python3.12?
When I'm in Python and use the arrow keys I see the escape characters: (e.g. ^[[A^[[B^[[C^[[A^[[D).
I want to just have the up arrow key go to last entry. So, my question is whether there's an ...
1
vote
0
answers
113
views
Accessing Readline's "application name" in Ruby
Is there any way (supported or otherwise) to set Readline's rl_readline_name variable from Ruby's Readline module? Or even to read it to find out the current value?
It seems to be only marginally ...
0
votes
0
answers
56
views
Reprint readline question after user input
I'm trying to use the user input on a readline question, to display it in front of the question after the user hits enter.
Currently i have a promisified question like this:
export const ...
1
vote
0
answers
60
views
Make readline tab cycle options within a C application
When using bash, if you run bind 'TAB:menu-complete' readline will cycle through all the possible matches. However I can't find a way to do the same in a C program that uses readline for input.
The ...
0
votes
1
answer
84
views
Python readline() bug, writes at eof
In python3 it seems that there is a bug with the readline() method.
I have a file txt.txt that contains two lines:
1234567890
abcdefghij
I then run the following code:
g = open("txt.txt",&...
0
votes
0
answers
150
views
Use ansi escape sequences to create a border between input and output
I am writing an app with streaming text output that needs to have an input area fixed to the bottom of the screen.
I am using node:readline and ansi-escapes and I just cannot figure out how to ...
1
vote
3
answers
298
views
Julia, read data from text file (Fortran- like)
How to convert following simple Fortran to Julia?
integer n,i,ne,m,k(10,2)
real x(10),a(10)
open(1,'t.txt')
READ(1,*) n,ne
do i=1,n
READ(1,*) m,x(m)
end do
do i=1,ne
READ(1,*) m,a(m),(k(m,...
1
vote
1
answer
39
views
readline: activating copies of both emacs-standard and emacs-meta keymaps
My aim is to:
Copy emacs-standard and emacs-meta keymaps,
Activate the copies
Make changes to the copies
Restore the emacs-standard and emacs-meta keymaps
I have read that emacs-meta is assigned to ...
0
votes
1
answer
168
views
Why is my 'await' line not working as expected?
Here is my code in Node.JS
const fs = require('fs');
const readline = require('readline');
const filePath = 'the/path/to/the/file';
const linesPerChunk = 20;
const readStream = fs....
0
votes
0
answers
141
views
Extra Prompt Displayed in GNU Readline
I'm writing a shell-like program in C using GNU readline and have encountered a bug related to prompt handling.
Brief Description of the Issue
In my program, after exiting a heredoc with ^D and then ...
0
votes
1
answer
331
views
Problem in controlling cursor position through readline in Node.js
I am designing a console app in Node.js using readline to control the cursor positions and get user input. Here is a library I have written for the same:
// ReadLine.js
const readline = require("...
0
votes
1
answer
44
views
C-W is deleting my command prompt - how to stop this
I'm working on a small shell and using libreadline to get command input.
problem
My command prompt is getting deleted when I use C-W
note this only happens after I enter a word and then C-W, C-w ...
0
votes
0
answers
218
views
Why does COMP_WORDBREAKS exists? What are usefull cases for using COMP_WORDBREAKS?
Many confused programmers stumbled upon COMP_WORDBREAKS. The documentation states https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html :
COMP_WORDBREAKS
The set of characters that ...