Questions tagged [readline]

A library for command line editing, or a function to read one line of text.

Readline may refer either the GNU readline library, used for editing a command line; or a function or method in various programming languages which typically reads a line of text from an open file handle.

GNU readline library

The gnu readline library provides applications with an interactive command prompt with features like

  • flexible command editing
  • configurable key bindings to mimic e.g. or
  • a history of past commands

Probably the most prominent application using readline is . Both packages are maintained by the same person. Many programming languages provide bindings for this library.

readline function

Examples of readline functions or methods include

(please extend this list if you know more languages using this name)

2233 questions
31
votes
2 answers

What is the correct way to ask for user input in an R program?

The my program below(which is in two parts) works if I run them separately – that is, if I paste the first part into the R Console, run it and then paste the second and run it. However, that is not how I want it. I want to run the whole program at…
Son
  • 5,295
  • 5
  • 19
  • 10
30
votes
12 answers

How to get Readline support in IRB using RVM on Ubuntu 11.10

I have tried everything I can think of to get this to work, to no avail so here I am requesting suggestions on how to debug. Firstly, runnning Ubuntu 11.10 Installed rvm: $ bash < <(curl -s…
ktec
  • 2,453
  • 3
  • 26
  • 32
29
votes
2 answers

Readline functionality on windows with python 2.7

I need to import the readline functionality in a program written in python. I am currently using version 2.7 and the 3rd party packages I have seen only work up to version 2.6. Does anyone know of a 3rd party readline package for Windows with Python…
Franz Payer
  • 4,069
  • 15
  • 53
  • 77
28
votes
3 answers

How do I open a terminal application from node.js?

I would like to be able to open Vim from node.js program running in the terminal, create some content, save and exit Vim, and then grab the contents of the file. I'm trying to do something like this: filename = '/tmp/tmpfile-' + process.pid editor…
mkopala
  • 1,262
  • 3
  • 12
  • 15
28
votes
4 answers

Reading a line from a streamreader without consuming?

Is there a way to read ahead one line to test if the next line contains specific tag data? I'm dealing with a format that has a start tag but no end tag. I would like to read a line add it to a structure then test the line below to make sure it not…
Crash893
  • 11,428
  • 21
  • 88
  • 123
27
votes
6 answers

Maximum line length for BufferedReader.readLine() in Java?

I use BufferedReader's readLine() method to read lines of text from a socket. There is no obvious way to limit the length of the line read. I am worried that the source of the data can (maliciously or by mistake) write a lot of data without any…
daphshez
  • 9,272
  • 11
  • 47
  • 65
26
votes
3 answers

Reading a file line by line into elements of an array in Python

So in Ruby I can do the following: testsite_array = Array.new y=0 File.open('topsites.txt').each do |line| testsite_array[y] = line y=y+1 end How would one do that in Python?
walterfaye
  • 819
  • 2
  • 9
  • 15
25
votes
6 answers

Using GNU Readline; how can I add ncurses in the same program?

The title is a bit more specific than my actual goal: I have a command-line program which uses GNU Readline, primarily for command history (i.e. retrieving previous commands using up-arrow) and some other niceties. Right now the program's output…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
25
votes
1 answer

IRB history not working with Ruby 2.3.0

I have Ruby 2.3.0p0 installed via rbenv, on OS X 10.11.4. Within an IRB session, history works fine. However, I cannot access IRB history across sessions. I tried my system Ruby, 2.0.0p648, and history across IRB sessions works fine. I tried…
Evan Pon
  • 1,496
  • 1
  • 13
  • 22
25
votes
8 answers

Most Robust way of reading a file or stream using Java (to prevent DoS attacks)

Currently I have the below code for reading an InputStream. I am storing the whole file into a StringBuilder variable and processing this string afterwards. public static String getContentFromInputStream(InputStream inputStream) // public static…
Unni Kris
  • 3,081
  • 4
  • 35
  • 57
25
votes
6 answers

read command doesn't wait for input

I have problem executing a simple script in bash. The script is like this: #! /bin/sh read -p 'press [ENTER] to continue deleting line' sudo sed -ie '$d' /home/hpccuser/.profile and when I execute the script with ./script the output is like…
24
votes
3 answers

How to fix column calculation in Python readline if using color prompt

I use standard tips for customizing interactive Python session: $ cat ~/.bashrc export PYTHONSTARTUP=~/.pystartup $ cat ~/.pystartup import os import sys import atexit import readline import rlcompleter historyPath =…
gavenkoa
  • 45,285
  • 19
  • 251
  • 303
24
votes
2 answers

In bash readline, how do I make the incremental search case insensitive

At the bash prompt, I can type Ctrl-r and Ctrl-s to perform incremental search of my command history. However, the search is case sensitive: If I have a command cat SomeFile.txt, and I hit "Ctrl-r somefile", I get nothing. Is there a way to make…
Martin C. Martin
  • 3,565
  • 3
  • 29
  • 36
23
votes
5 answers

How to read utf16 text file to string in golang?

I can read the file to bytes array but when I convert it to string it treat the utf16 bytes as ascii How to convert it correctly? package main import ("fmt" "os" "bufio" ) func main(){ // read whole the file f, err := os.Open("test.txt") …
CL So
  • 3,647
  • 10
  • 51
  • 95
22
votes
1 answer

Use readline to read txt file python3

I been working on this for hours and I cant get it right, any help would be appreciated! My question is how do I use the function .readline() to read until the end of a text file? I know that .readlines() work as well but I'm trying to process one…
Code971
  • 325
  • 1
  • 2
  • 4