Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

You will lose an important tape file.


devel / comp.unix.shell / [ksh] Readline support in a read-loop ?

SubjectAuthor
* [ksh] Readline support in a read-loop ?Janis Papanagnou
+* Re: [ksh] Readline support in a read-loop ?Joerg Mertens
|`- Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
+* Re: [ksh] Readline support in a read-loop ?Kenny McCormack
|`* Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
| `* Tecla builtin for bash (Was: [ksh] Readline support in a read-loop ?)Kenny McCormack
|  `* Re: Tecla builtin for bash (Was: [ksh] Readline support in a read-loop ?)Janis Papanagnou
|   `* Why do you say it didn't work? (Was: Tecla builtin for bash (Was: [ksh] ReadlineKenny McCormack
|    `- Re: Why do you say it didn't work? (Was: Tecla builtin for bash (Was: [ksh] ReadJanis Papanagnou
+* Re: [ksh] Readline support in a read-loop ?Christian Weisgerber
|+* What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Kenny McCormack
||+- Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Lew Pitcher
||`* Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Christian Weisgerber
|| `* Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Janis Papanagnou
||  `* Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Christian Weisgerber
||   +- Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Kenny McCormack
||   `* Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Jim Jackson
||    +- Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Janis Papanagnou
||    `- Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)Christian Weisgerber
|`- Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
+* Re: [ksh] Readline support in a read-loop ?Eric Pozharski
|`* Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
| `- Re: [ksh] Readline support in a read-loop ?Chuck Martin
+* Re: [ksh] Readline support in a read-loop ?jeorge
|`- Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
`* Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
 `* Re: [ksh] Readline support in a read-loop ?Martijn Dekker
  +- Re: [ksh] Readline support in a read-loop ?Janis Papanagnou
  `* Re: bash/ksh: Readline support in a read-loop ?Kenny McCormack
   +* Re: bash/ksh: Readline support in a read-loop ?Christian Weisgerber
   |`* Re: bash/ksh: Readline support in a read-loop ?Kenny McCormack
   | `* Re: bash/ksh: Readline support in a read-loop ?Janis Papanagnou
   |  `- Re: bash/ksh: Readline support in a read-loop ?Kenny McCormack
   `- Re: bash/ksh: Readline support in a read-loop ?Janis Papanagnou

Pages:12
[ksh] Readline support in a read-loop ?

<untn92$3t3gn$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7580&group=comp.unix.shell#7580

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 11:05:21 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <untn92$3t3gn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Jan 2024 10:05:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6951171f9c281a8d390a515a3f488c18";
logging-data="4099607"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/e+lt91ZHffc3y2ppyQ/pn"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:ivzFqRgeoZx9zIpIpquDwfurRJg=
X-Enigmail-Draft-Status: N1110
X-Mozilla-News-Host: news://news.eternal-september.org:119
 by: Janis Papanagnou - Sat, 13 Jan 2024 10:05 UTC

I'm having a Kornshell script that prompts for input like this

while IFS= read -r word?"prompt> "
do process "${word}"
done

Is there a possibility to somehow get readline(3) editing support
into such a read loop, so that whenever the prompt is displayed I
can skim (e.g. with cursor keys) through the previous data input?

If not in ksh; is that maybe possible in bash or zsh ?

Or is there a general problem with that idea or such a function?

Janis

Re: [ksh] Readline support in a read-loop ?

<87wmsda0fe.fsf@jmertens.eternal-september.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7581&group=comp.unix.shell#7581

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!jmertens.eternal-september.org!.POSTED!not-for-mail
From: joerg-mertens@t-online.de (Joerg Mertens)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 13:21:41 +0100
Organization: privat
Lines: 24
Message-ID: <87wmsda0fe.fsf@jmertens.eternal-september.org>
References: <untn92$3t3gn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: jmertens.eternal-september.org; posting-host="3e643bbc8ad33768782b14dd9b8a2bfc";
logging-data="4137467"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/z7v56tS/LYPHfO30W+3aUCV0C8/vufZw="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:YgesW4tV0QrssvTxwMGYyNZix5w=
sha1:tjQ592c+ZC3wkZ1Tb/Ck0gI/DBQ=
 by: Joerg Mertens - Sat, 13 Jan 2024 12:21 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

> I'm having a Kornshell script that prompts for input like this
>
> while IFS= read -r word?"prompt> "
> do process "${word}"
> done
>
> Is there a possibility to somehow get readline(3) editing support
> into such a read loop, so that whenever the prompt is displayed I
> can skim (e.g. with cursor keys) through the previous data input?
>
> If not in ksh; is that maybe possible in bash or zsh ?
>
> Or is there a general problem with that idea or such a function?

You can start your shell with `rlwrap -a´. This should provide readline
support on every prompt. However unfortunately this way readline cannot
distinguish between the read prompts and the other prompts.

Another possibility would be to start an external program which reads
and prints a single line and then wrap this program with rlwrap. Then
in your script you should be able to capture the line with
`word="$(program)"´.

Re: [ksh] Readline support in a read-loop ?

<unu193$1vvjp$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7582&group=comp.unix.shell#7582

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 12:56:03 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <unu193$1vvjp$1@news.xmission.com>
References: <untn92$3t3gn$1@dont-email.me>
Injection-Date: Sat, 13 Jan 2024 12:56:03 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2096761"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 13 Jan 2024 12:56 UTC

In article <untn92$3t3gn$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>I'm having a Kornshell script that prompts for input like this
>
> while IFS= read -r word?"prompt> "
> do process "${word}"
> done
>
>Is there a possibility to somehow get readline(3) editing support
>into such a read loop, so that whenever the prompt is displayed I
>can skim (e.g. with cursor keys) through the previous data input?
>
>If not in ksh; is that maybe possible in bash or zsh ?

Don't know much about ksh (don't much about the French I took), but bash
will do this quite easily. Just include "-e" as an option to "read".

>Or is there a general problem with that idea or such a function?

No, seems perfectly reasonable to me.

FWIW, I actually don't like readline much. Prefer "Tecla" (you can Google
it). I wrote a bash extension library that gives me access to Tecla from
my bash scripts. The extension library creates a new builtin command
"getline" that has Tecla editing functionality.

--
I love the poorly educated.

Re: [ksh] Readline support in a read-loop ?

<unu4h3$3v0o3$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7583&group=comp.unix.shell#7583

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 14:51:30 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <unu4h3$3v0o3$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<87wmsda0fe.fsf@jmertens.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Jan 2024 13:51:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6951171f9c281a8d390a515a3f488c18";
logging-data="4162307"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OAgOQrYOPwpexHMyWNxvf"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:/5b2l3t1fv4CInnaAETRWN6Xr1A=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <87wmsda0fe.fsf@jmertens.eternal-september.org>
 by: Janis Papanagnou - Sat, 13 Jan 2024 13:51 UTC

On 13.01.2024 13:21, Joerg Mertens wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> I'm having a Kornshell script that prompts for input like this
>>
>> while IFS= read -r word?"prompt> "
>> do process "${word}"
>> done
>>
>> Is there a possibility to somehow get readline(3) editing support
>> into such a read loop, so that whenever the prompt is displayed I
>> can skim (e.g. with cursor keys) through the previous data input?
>>
>> If not in ksh; is that maybe possible in bash or zsh ?
>>
>> Or is there a general problem with that idea or such a function?
>
> You can start your shell with `rlwrap -a´. This should provide readline
> support on every prompt. However unfortunately this way readline cannot
> distinguish between the read prompts and the other prompts.

Looks interesting. The docs also mention some more tools. - Thanks.

Too bad that it has no configure script and it requires some newer
version of Autoconf to build, so currently I can't compile it as
it is on my Linux. Will have to look into it later...

>
> Another possibility would be to start an external program which reads
> and prints a single line and then wrap this program with rlwrap. Then
> in your script you should be able to capture the line with
> `word="$(program)"´.

I also thought in that direction as a fall-back if there's nothing
already existing. My first thoughts were to use ksh's KEYBD trap,
maybe in conjunction with a 'set' discipline function on the 'read'
variable. But first I look whether I can avoid to invent something
new.

Janis

Re: [ksh] Readline support in a read-loop ?

<unu4rb$3v226$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7584&group=comp.unix.shell#7584

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 14:56:58 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <unu4rb$3v226$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me> <unu193$1vvjp$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Jan 2024 13:56:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6951171f9c281a8d390a515a3f488c18";
logging-data="4163654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uP0yav+iH0fF1fvkVdOwB"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:cK5RaJzEWDWR/C57MAd7DndZEMU=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <unu193$1vvjp$1@news.xmission.com>
 by: Janis Papanagnou - Sat, 13 Jan 2024 13:56 UTC

On 13.01.2024 13:56, Kenny McCormack wrote:
> In article <untn92$3t3gn$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> I'm having a Kornshell script that prompts for input like this
>>
>> while IFS= read -r word?"prompt> "
>> do process "${word}"
>> done
>>
>> Is there a possibility to somehow get readline(3) editing support
>> into such a read loop, so that whenever the prompt is displayed I
>> can skim (e.g. with cursor keys) through the previous data input?
>>
>> If not in ksh; is that maybe possible in bash or zsh ?
>
> Don't know much about ksh (don't much about the French I took), but bash
> will do this quite easily. Just include "-e" as an option to "read".

I had searched the bash man page for readline but somehow missed it
(maybe a typo); but it is there. - Thanks.

I inspected my script and it may be the least effort to just port
it from ksh to bash; there's not much ksh specific in it. It seems
that this is the most convenient solution for me.

>
>> Or is there a general problem with that idea or such a function?
>
> No, seems perfectly reasonable to me.
>
> FWIW, I actually don't like readline much. Prefer "Tecla" (you can Google
> it). I wrote a bash extension library that gives me access to Tecla from
> my bash scripts. The extension library creates a new builtin command
> "getline" that has Tecla editing functionality.

I'd be interested to have a look into the built-in. Is it available
to the public?

Janis

Re: [ksh] Readline support in a read-loop ?

<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7585&group=comp.unix.shell#7585

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.neodome.net!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 13:32:01 -0000 (UTC)
Message-ID: <slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
References: <untn92$3t3gn$1@dont-email.me>
Injection-Date: Sat, 13 Jan 2024 13:32:01 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="68147"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sat, 13 Jan 2024 13:32 UTC

On 2024-01-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> Is there a possibility to somehow get readline(3) editing support
> into such a read loop, so that whenever the prompt is displayed I
> can skim (e.g. with cursor keys) through the previous data input?
>
> If not in ksh; is that maybe possible in bash or zsh ?

Not in bash, where "read -e" will use readline(3), but it doesn't
keep any history, so you can't access previous input. It's possible
to put some text into the readline edit buffer (-i text), so you
could, say, offer the immediately previous input as a default.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<unu848$201hg$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7586&group=comp.unix.shell#7586

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)
Date: Sat, 13 Jan 2024 14:52:56 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <unu848$201hg$1@news.xmission.com>
References: <untn92$3t3gn$1@dont-email.me> <slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
Injection-Date: Sat, 13 Jan 2024 14:52:56 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2098736"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 13 Jan 2024 14:52 UTC

In article <slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>,
Christian Weisgerber <naddy@mips.inka.de> wrote:
>On 2024-01-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> Is there a possibility to somehow get readline(3) editing support
>> into such a read loop, so that whenever the prompt is displayed I
>> can skim (e.g. with cursor keys) through the previous data input?
>>
>> If not in ksh; is that maybe possible in bash or zsh ?
>
>Not in bash, where "read -e" will use readline(3), but it doesn't
>keep any history, so you can't access previous input.

No idea what you're on about here. It works as expected for me.

--
"The party of Lincoln has become the party of John Wilkes Booth."

- Carlos Alazraqui -

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<unu8sd$3vfrg$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7587&group=comp.unix.shell#7587

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.samoylyk.net!news.szaf.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitcher@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sat, 13 Jan 2024 15:05:49 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <unu8sd$3vfrg$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Jan 2024 15:05:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5ef5b9d2460f5bb2e060f282e8d2e82c";
logging-data="4177776"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Yj/fDlbRApUqhFW6/uWo0RJnA2DUkzCg="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:+9iPi2fkRE/+ONwFaqVSCLGPrD8=
 by: Lew Pitcher - Sat, 13 Jan 2024 15:05 UTC

On Sat, 13 Jan 2024 14:52:56 +0000, Kenny McCormack wrote:

> In article <slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>,
> Christian Weisgerber <naddy@mips.inka.de> wrote:
>>On 2024-01-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>
>>> Is there a possibility to somehow get readline(3) editing support
>>> into such a read loop, so that whenever the prompt is displayed I
>>> can skim (e.g. with cursor keys) through the previous data input?
>>>
>>> If not in ksh; is that maybe possible in bash or zsh ?
>>
>>Not in bash, where "read -e" will use readline(3), but it doesn't
>>keep any history, so you can't access previous input.
>
> No idea what you're on about here. It works as expected for me.

I've never used this bash feature myself, so I don't have any firsthand
knowledge of it.

HOWEVER, it appears that bash(1) uses certain user-configurable
settings[1] to enable or disable the "history" options of bash(1)'s
"read -e"

P'haps Christian does not have these options enabled (thus causing
"read -e" to ignore line history), and you /do/ have them enabled
(either by choice, or by default).

[1] See bash(1) "READLINE" section, specifically the "Readline
Variables" subsection, and the "Readline Initialization" subsection
for information on how to enable/disable history.
--
Lew Pitcher
"In Skills We Trust"

Tecla builtin for bash (Was: [ksh] Readline support in a read-loop ?)

<unu914$201hg$2@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7588&group=comp.unix.shell#7588

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.hispagatos.org!news.nntp4.net!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!1.us.feeder.erje.net!feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Tecla builtin for bash (Was: [ksh] Readline support in a read-loop ?)
Date: Sat, 13 Jan 2024 15:08:20 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <unu914$201hg$2@news.xmission.com>
References: <untn92$3t3gn$1@dont-email.me> <unu193$1vvjp$1@news.xmission.com> <unu4rb$3v226$1@dont-email.me>
Injection-Date: Sat, 13 Jan 2024 15:08:20 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2098736"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 13 Jan 2024 15:08 UTC

In article <unu4rb$3v226$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>> FWIW, I actually don't like readline much. Prefer "Tecla" (you can Google
>> it). I wrote a bash extension library that gives me access to Tecla from
>> my bash scripts. The extension library creates a new builtin command
>> "getline" that has Tecla editing functionality.
>
>I'd be interested to have a look into the built-in. Is it available
>to the public?

I can post it here, if you like. Give me a little time to get it together
for posting.

--
"The most unsettling aspect of my atheism for Christians is
when they realize that their Bible has no power to make me
wince. They are used to using it like a cattle prod to get
people to cower into compliance." - Author unknown

Re: Tecla builtin for bash (Was: [ksh] Readline support in a read-loop ?)

<unuc23$3ve$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7589&group=comp.unix.shell#7589

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Tecla builtin for bash (Was: [ksh] Readline support in a
read-loop ?)
Date: Sat, 13 Jan 2024 17:00:03 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <unuc23$3ve$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me> <unu193$1vvjp$1@news.xmission.com>
<unu4rb$3v226$1@dont-email.me> <unu914$201hg$2@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Jan 2024 16:00:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6951171f9c281a8d390a515a3f488c18";
logging-data="4078"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Vww7iZBaMOQENOqAgddkf"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Tg5HopNi7mpi0freeGi5YrdNl4s=
In-Reply-To: <unu914$201hg$2@news.xmission.com>
 by: Janis Papanagnou - Sat, 13 Jan 2024 16:00 UTC

On 13.01.2024 16:08, Kenny McCormack wrote:
> In article <unu4rb$3v226$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>>> FWIW, I actually don't like readline much. Prefer "Tecla" (you can Google
>>> it). I wrote a bash extension library that gives me access to Tecla from
>>> my bash scripts. The extension library creates a new builtin command
>>> "getline" that has Tecla editing functionality.
>>
>> I'd be interested to have a look into the built-in. Is it available
>> to the public?
>
> I can post it here, if you like. Give me a little time to get it together
> for posting.

Thanks. And don't worry or hurry, I have plenty of time. :-)

My tries with bash's read -e failed BTW; yet I have no idea
why it doesn't work. - Will have to examine it...

Janis

Re: [ksh] Readline support in a read-loop ?

<unucn3$88a$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7590&group=comp.unix.shell#7590

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 17:11:14 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <unucn3$88a$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Jan 2024 16:11:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6951171f9c281a8d390a515a3f488c18";
logging-data="8458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cQtwx30wn0obqLkky5H52"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:+jfAn28Z8Xdc6wifrxZ4C3EvbeE=
In-Reply-To: <slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 13 Jan 2024 16:11 UTC

On 13.01.2024 14:32, Christian Weisgerber wrote:
> On 2024-01-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> Is there a possibility to somehow get readline(3) editing support
>> into such a read loop, so that whenever the prompt is displayed I
>> can skim (e.g. with cursor keys) through the previous data input?
>>
>> If not in ksh; is that maybe possible in bash or zsh ?
>
> Not in bash, where "read -e" will use readline(3), but it doesn't
> keep any history, so you can't access previous input. It's possible
> to put some text into the readline edit buffer (-i text), so you
> could, say, offer the immediately previous input as a default.

This is what I experienced as well. So I'll have to look into it.
Lew's comment indicates that there might be some hope to solve it
by configuration. I'll see what I find and get...

BTW, the injection of default data into the read prompt is also
possible in Kornshell. (I tried it in both shells.) But it's not
what I need, because I'd then have to clear it constantly, since
my "normal" use-case is to type in new phrases, but occasionally
I want some older phrases (mostly the last one) corrected.

BTW #2, my (desperate) latest try was to define a KEYBD trap and
if .sh.edchar is a Tab it should replace the input by the data
line from a tool specific history file, and use ksh's read -s
option. - It also doesn't work; at least not yet...

Janis

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7591&group=comp.unix.shell#7591

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.chmurka.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sat, 13 Jan 2024 15:48:16 -0000 (UTC)
Message-ID: <slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
Injection-Date: Sat, 13 Jan 2024 15:48:16 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="70570"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sat, 13 Jan 2024 15:48 UTC

On 2024-01-13, Kenny McCormack <gazelle@shell.xmission.com> wrote:

>>Not in bash, where "read -e" will use readline(3), but it doesn't
>>keep any history, so you can't access previous input.
>
> No idea what you're on about here.

What I said.

Anybody can try it for themselves:

while IFS= read -r -e -p "prompt> " line
do
echo "[$line]"
done

Actually, the lack of history is only true if you run it in a script.
In an interactive shell, there is history--but it's the command
history and it does not include the "read" input.

Bash 5.2.21.
--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: [ksh] Readline support in a read-loop ?

<slrnuq5fks.37t.apple.universe@freight.zombinet>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7593&group=comp.unix.shell#7593

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 16:47:24 +0000
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <slrnuq5fks.37t.apple.universe@freight.zombinet>
References: <untn92$3t3gn$1@dont-email.me>
Injection-Info: dont-email.me; posting-host="6c4755d49727b8c26cef755111fee9e5";
logging-data="55773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+y1yKxyzeLamcdsitAOswy"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:e1nWhRWwoI8YDpGWQ1sdkGpTuac=
 by: Eric Pozharski - Sat, 13 Jan 2024 16:47 UTC

with <untn92$3t3gn$1@dont-email.me> Janis Papanagnou wrote:

> I'm having a Kornshell script that prompts for input like this
>
> while IFS= read -r word?"prompt> "
> do process "${word}"
> done
>
> Is there a possibility to somehow get readline(3) editing support into
> such a read loop, so that whenever the prompt is displayed I can skim
> (e.g. with cursor keys) through the previous data input?
>
> If not in ksh; is that maybe possible in bash or zsh ?

As of zsh (disclaimer: not a ksh-user here)

% typeset foo= ; vared -p '### ' foo ; echo "($?) ($foo)"
### aa bb cc
(0) (aa bb cc)

More information 'info zsh vared'. What manual is trying to say should
be discovered through experiments though. Another caveat: it's not
clear from getgo if 'vared' would read from stdin and then go for
editing. Yet another caveat: in 5min I failed to find out how to
achieve multiline input. Also: obviously it's not readline(3), it's
zle. Are you distracted enough now?

*CUT* [ 4 lines 1 level deep]

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Re: [ksh] Readline support in a read-loop ?

<unun61$qhs$1@nnrp.usenet.blueworldhosting.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7594&group=comp.unix.shell#7594

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.neodome.net!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED!not-for-mail
From: someone@invalid.invalid (jeorge)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sat, 13 Jan 2024 12:09:52 -0700
Organization: Ministry of Madness
Message-ID: <unun61$qhs$1@nnrp.usenet.blueworldhosting.com>
References: <untn92$3t3gn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Jan 2024 19:09:53 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com;
logging-data="27196"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vMmI96LvVW8K4faXxFDpLSk1n7o= sha256:nLayRDNoW0FiG7KRgcEnn9wOu1b1UCIbwtpjFstqXLc=
sha1:sw201+hnBdg6h/esH0sGCo24dVc= sha256:2jbzdObslncPsvMEhBoqEoxlBaHk7TWqkroBVIPKOFs=
In-Reply-To: <untn92$3t3gn$1@dont-email.me>
Content-Language: en-US
 by: jeorge - Sat, 13 Jan 2024 19:09 UTC

On 1/13/24 3:05 AM, Janis Papanagnou wrote:
> I'm having a Kornshell script that prompts for input like this
>
> while IFS= read -r word?"prompt> "
> do process "${word}"
> done
>
> Is there a possibility to somehow get readline(3) editing support
> into such a read loop, so that whenever the prompt is displayed I
> can skim (e.g. with cursor keys) through the previous data input?
>
> If not in ksh; is that maybe possible in bash or zsh ?
>
> Or is there a general problem with that idea or such a function?

A while back I was playing with ksh93 and wrote a "Word Of The Day"
script presents randomly selected words -- a through z -- from the
system "words" file which can then be selected for dictionary lookup.

Temporary history files to seed "adjacent words",
core_word+{s,es,ist,etc}, in the event a definition for the selected
word wasn't found. The suggested adjacent word(s) are selected via the
Up/Down arrows and can then be edited similar to readline.

Anyway, maybe it's useful to you:

gopher://sdf.org/0/users/jgw/Misc/wotd.ksh

* lynx(1) or curl(1) support gopher links

jeorge

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<unvdd8$5i0p$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7595&group=comp.unix.shell#7595

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 02:29:11 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <unvdd8$5i0p$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 Jan 2024 01:29:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10f7ea81c55ec0586e7ee680a31aba28";
logging-data="182297"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wTxQWLHgpbv35CwzPeLrw"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:jeRz/2ejoTi3P3gZxDJHfu7gHDo=
In-Reply-To: <slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 14 Jan 2024 01:29 UTC

On 13.01.2024 16:48, Christian Weisgerber wrote:
> On 2024-01-13, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>
>>> Not in bash, where "read -e" will use readline(3), but it doesn't
>>> keep any history, so you can't access previous input.
>>
>> No idea what you're on about here.
>
> What I said.
>
> Anybody can try it for themselves:
>
> while IFS= read -r -e -p "prompt> " line
> do
> echo "[$line]"
> done
>
> Actually, the lack of history is only true if you run it in a script.
> In an interactive shell, there is history--but it's the command
> history and it does not include the "read" input.

That would be okay (at least for ksh) since ksh's 'read -s' allows to
drop the read input to the command history. (But ksh doesn't have the
'read -e', OTOH. I thought the requirement would not be uncommon and
some [emphasis!] _easy_ support would be in the shells, but no, it's
cursed.)

Janis, continuing later...

Re: [ksh] Readline support in a read-loop ?

<unvdjg$5iue$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7596&group=comp.unix.shell#7596

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sun, 14 Jan 2024 02:32:31 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <unvdjg$5iue$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq5fks.37t.apple.universe@freight.zombinet>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 Jan 2024 01:32:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10f7ea81c55ec0586e7ee680a31aba28";
logging-data="183246"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rk+REvfTIUDUh+Dj+DkD/"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:+2cFjbJjNl+qlzf/dpgT6ITsKCw=
In-Reply-To: <slrnuq5fks.37t.apple.universe@freight.zombinet>
 by: Janis Papanagnou - Sun, 14 Jan 2024 01:32 UTC

On 13.01.2024 17:47, Eric Pozharski wrote:
> with <untn92$3t3gn$1@dont-email.me> Janis Papanagnou wrote:
>> [...]
>>
>> Is there a possibility to somehow get readline(3) editing support into
>> such a read loop, so that whenever the prompt is displayed I can skim
>> (e.g. with cursor keys) through the previous data input?
>>
>> If not in ksh; is that maybe possible in bash or zsh ?
>
> As of zsh (disclaimer: not a ksh-user here)
>
> % typeset foo= ; vared -p '### ' foo ; echo "($?) ($foo)"
> ### aa bb cc
> (0) (aa bb cc)
>
> More information 'info zsh vared'. What manual is trying to say should
> be discovered through experiments though. Another caveat: it's not
> clear from getgo if 'vared' would read from stdin and then go for
> editing. Yet another caveat: in 5min I failed to find out how to
> achieve multiline input. Also: obviously it's not readline(3), it's
> zle. Are you distracted enough now?

Both would be okay. (I neither need multiline, nor a specific readline
function.) I just want to be able to get and edit previous inputs most
simply and least disturbing. - I'll look into it. Thanks.

Janis

Re: [ksh] Readline support in a read-loop ?

<unve08$5k3m$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7597&group=comp.unix.shell#7597

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.1d4.us!news.samoylyk.net!nyheter.lysator.liu.se!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Readline support in a read-loop ?
Date: Sun, 14 Jan 2024 02:39:19 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <unve08$5k3m$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<unun61$qhs$1@nnrp.usenet.blueworldhosting.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 Jan 2024 01:39:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="af0041c79726314c422635634ec5f39f";
logging-data="184438"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QhrXalazac9/WyEGAGIre"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:I/A9f92YAlJS4mE2Yg3hBKAWnRM=
In-Reply-To: <unun61$qhs$1@nnrp.usenet.blueworldhosting.com>
 by: Janis Papanagnou - Sun, 14 Jan 2024 01:39 UTC

On 13.01.2024 20:09, jeorge wrote:
>
> A while back I was playing with ksh93 and wrote a "Word Of The Day"
> script presents [...]
>
> Anyway, maybe it's useful to you:

Quite some code; I'll have a look into it but need some time. - Thanks.

>
> gopher://sdf.org/0/users/jgw/Misc/wotd.ksh

Legacy feelings come up... :-)

I used gopher maybe once around 1990; is it still in use?
(Good that curl supports it; thanks for the hint.)

Janis

Re: [ksh] Readline support in a read-loop ?

<slrnuq72c8.r17i.cmartin+usenetYYMMDD@nyx2.nyx.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7598&group=comp.unix.shell#7598

  copy link   Newsgroups: comp.unix.shell
Newsgroups: comp.unix.shell
From: cmartin+usenetYYMMDD@nyx.net (Chuck Martin)
Subject: Re: [ksh] Readline support in a read-loop ?
References: <untn92$3t3gn$1@dont-email.me> <slrnuq5fks.37t.apple.universe@freight.zombinet> <unvdjg$5iue$1@dont-email.me>
User-Agent: slrn/1.0.3 (Linux)
Message-Id: <slrnuq72c8.r17i.cmartin+usenetYYMMDD@nyx2.nyx.net>
Organization: NewsDemon - www.newsdemon.com
Cache-Post-Path: nyx2.nyx.net!64642@localhost
X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/)
Lines: 38
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!news.newsdemon.com!not-for-mail
Date: Sun, 14 Jan 2024 07:13:13 +0000
Nntp-Posting-Date: Sun, 14 Jan 2024 07:13:13 +0000
X-Received-Bytes: 2449
X-Complaints-To: abuse@newsdemon.com
 by: Chuck Martin - Sun, 14 Jan 2024 07:13 UTC

On 2024-01-14, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 13.01.2024 17:47, Eric Pozharski wrote:
>> with <untn92$3t3gn$1@dont-email.me> Janis Papanagnou wrote:
>>> [...]
>>>
>>> Is there a possibility to somehow get readline(3) editing support into
>>> such a read loop, so that whenever the prompt is displayed I can skim
>>> (e.g. with cursor keys) through the previous data input?
>>>
>>> If not in ksh; is that maybe possible in bash or zsh ?
>>
>> As of zsh (disclaimer: not a ksh-user here)
>>
>> % typeset foo= ; vared -p '### ' foo ; echo "($?) ($foo)"
>> ### aa bb cc
>> (0) (aa bb cc)
>>
>> More information 'info zsh vared'. What manual is trying to say should
>> be discovered through experiments though. Another caveat: it's not
>> clear from getgo if 'vared' would read from stdin and then go for
>> editing. Yet another caveat: in 5min I failed to find out how to
>> achieve multiline input. Also: obviously it's not readline(3), it's
>> zle. Are you distracted enough now?
>
> Both would be okay. (I neither need multiline, nor a specific readline
> function.) I just want to be able to get and edit previous inputs most
> simply and least disturbing. - I'll look into it. Thanks.

The vared command needs -h to use the history. You can also use fc -p
before using the vared command to push the current history onto a stack
and switch to a new history list. The fc command can be found in
"man zshbuiltins" and the vared command in "man zshzle".

--
To reply via e-mail, replace "YYMMDD" with the current date in the
appropriate format, or your mail will bounce. Removing the + and
everything that follows in my username will also cause your mail to
bounce. Details: https://nyx.net/~cmartin/HowToEmailMe

Why do you say it didn't work? (Was: Tecla builtin for bash (Was: [ksh] Readline support in a) read-loop ?)

<uo0m2i$12go$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7599&group=comp.unix.shell#7599

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Why do you say it didn't work? (Was: Tecla builtin for bash (Was: [ksh] Readline support in a)
read-loop ?)
Date: Sun, 14 Jan 2024 13:03:14 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <uo0m2i$12go$1@news.xmission.com>
References: <untn92$3t3gn$1@dont-email.me> <unu4rb$3v226$1@dont-email.me> <unu914$201hg$2@news.xmission.com> <unuc23$3ve$1@dont-email.me>
Injection-Date: Sun, 14 Jan 2024 13:03:14 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="35352"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 14 Jan 2024 13:03 UTC

In article <unuc23$3ve$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>My tries with bash's read -e failed BTW; yet I have no idea
>why it doesn't work. - Will have to examine it...

In what way did it "not work" ?

See the other thread I entered on this. As far as I can tell, in-the-line
editing does work, but history doesn't. Is history the main functionality
that you need?

FWIW, it sure seems to me that there should be a way to get history to work.

--
The whole aim of practical politics is to keep the populace alarmed (and hence clamorous
to be led to safety) by menacing it with an endless series of hobgoblins, all of them imaginary.

H. L. Mencken

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7600&group=comp.unix.shell#7600

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 14:08:16 -0000 (UTC)
Message-ID: <slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de> <unvdd8$5i0p$1@dont-email.me>
Injection-Date: Sun, 14 Jan 2024 14:08:16 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="95610"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sun, 14 Jan 2024 14:08 UTC

On 2024-01-14, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> That would be okay (at least for ksh) since ksh's 'read -s' allows to
> drop the read input to the command history.

Bash also has a way to push commands into history. And in an
_interactive_ shell, "read -e" has access to history. Also, it
looks like the loop is considered a single command. We can combine
all this:

#!/usr/local/bin/bash -i
while IFS= read -r -e -p "prompt> " line
do
echo "[$line]"
history -s "$line"
done

It seems fragile, though, depending on underspecified behavior.
And I lack an understanding of the consequences of forcing a shell
to run as if interactive when executing a script.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<uo137g$18oe$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7601&group=comp.unix.shell#7601

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!1.us.feeder.erje.net!feeder.erje.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 16:47:44 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <uo137g$18oe$1@news.xmission.com>
References: <untn92$3t3gn$1@dont-email.me> <slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de> <unvdd8$5i0p$1@dont-email.me> <slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>
Injection-Date: Sun, 14 Jan 2024 16:47:44 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="41742"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 14 Jan 2024 16:47 UTC

In article <slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>,
Christian Weisgerber <naddy@mips.inka.de> wrote:
....
> #!/usr/local/bin/bash -i
> while IFS= read -r -e -p "prompt> " line
> do
> echo "[$line]"
> history -s "$line"
> done

Wow. I just tried adding "-i" to my script (see other thread) - and it
works - or does it?

If you add -i, you get history, but the history is the script itself, not
things you've previously entered at the prompt. So, that's no good.

--
The difference between communism and capitalism?
In capitalism, man exploits man. In communism, it's the other way around.

- Daniel Bell, The End of Ideology (1960) -

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<slrnuq8920.7hv.jj@iridium.wf32df>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7602&group=comp.unix.shell#7602

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jj@franjam.org.uk (Jim Jackson)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 18:13:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <slrnuq8920.7hv.jj@iridium.wf32df>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de> <unvdd8$5i0p$1@dont-email.me>
<slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>
Injection-Date: Sun, 14 Jan 2024 18:13:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e973b130eed2f8307795646387fa0303";
logging-data="582606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vaEgltnoXfK+B0+fxrVE8IRAgZn+QFFw="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:bCZaCX+mUQGnk2fLsgJHs/EMimQ=
 by: Jim Jackson - Sun, 14 Jan 2024 18:13 UTC

On 2024-01-14, Christian Weisgerber <naddy@mips.inka.de> wrote:
> On 2024-01-14, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> That would be okay (at least for ksh) since ksh's 'read -s' allows to
>> drop the read input to the command history.
>
> Bash also has a way to push commands into history. And in an
> _interactive_ shell, "read -e" has access to history. Also, it
> looks like the loop is considered a single command. We can combine
> all this:
>
> #!/usr/local/bin/bash -i
> while IFS= read -r -e -p "prompt> " line
> do
> echo "[$line]"
> history -s "$line"
> done
>
> It seems fragile, though, depending on underspecified behavior.
> And I lack an understanding of the consequences of forcing a shell
> to run as if interactive when executing a script.
>

This works for me. It's the stripped down version of a couple of scripts
I use every login session ...

#!/bin/bash

HISTFILE=$HOME/.history.test
HISTNUM=200

while $loop ; do
echo
set -H -o history
history -r
read -p "prompt : " -e ans
echo "$ans" >> $HISTFILE
case "$ans" in
q|quit|Q|Quit|QUIT)
exit 0
;;
esac
done

HTH
Jim

Re: Why do you say it didn't work? (Was: Tecla builtin for bash (Was: [ksh] Readline support in a) read-loop ?)

<uo19kf$i49t$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7603&group=comp.unix.shell#7603

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Why do you say it didn't work? (Was: Tecla builtin for bash (Was:
[ksh] Readline support in a) read-loop ?)
Date: Sun, 14 Jan 2024 19:37:03 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <uo19kf$i49t$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me> <unu4rb$3v226$1@dont-email.me>
<unu914$201hg$2@news.xmission.com> <unuc23$3ve$1@dont-email.me>
<uo0m2i$12go$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 Jan 2024 18:37:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ea51873a42b0fc7a055c65b5edf31db2";
logging-data="594237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DnBdf2QCOMEiQ4GhAIb0c"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:VOnbYXtytU7qyfqIGNG78VVT/58=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <uo0m2i$12go$1@news.xmission.com>
 by: Janis Papanagnou - Sun, 14 Jan 2024 18:37 UTC

On 14.01.2024 14:03, Kenny McCormack wrote:
> In article <unuc23$3ve$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>> My tries with bash's read -e failed BTW; yet I have no idea
>> why it doesn't work. - Will have to examine it...

Yet I haven't found the time to continue the examinations. So just a
short reply here...

>
> In what way did it "not work" ?

I tried with my code and also with the small sample that you provided,
setting up the two files, etc. - The effect was that I got my prompt
but arrows (or vi keys or any other random keys) did not show previous
input.

>
> See the other thread I entered on this. As far as I can tell, in-the-line
> editing does work, but history doesn't. Is history the main functionality
> that you need?

Yes exactly.

Entering text on the prompt and typing arrow keys on the actual input
will position the cursor so that I can, for example, insert some more
text. (Previously the left-arrow key just created ^[[D^[[D^[[D ...)

What I primarily needed was to get the previously entered data (which
has already be confirmed by <return>) back into the prompt. If I can't
reload the previous text into the prompt the arrow-movement isn't very
useful [on the empty prompt].

The use-case is that I send words to a server and depending on the
server response I may have to adjust/refine the previous input (without
typing all again).

Sorry if I was unclear about that.

>
> FWIW, it sure seems to me that there should be a way to get history to work.

Yeah, I have to see...

Janis

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<uo1ac9$i7n3$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7604&group=comp.unix.shell#7604

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 19:49:45 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uo1ac9$i7n3$1@dont-email.me>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de> <unvdd8$5i0p$1@dont-email.me>
<slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>
<slrnuq8920.7hv.jj@iridium.wf32df>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 14 Jan 2024 18:49:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ea51873a42b0fc7a055c65b5edf31db2";
logging-data="597731"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OCYLJdCNv0/oO9adT+Swd"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:CZOeuN+XnwIU5n4RN6olb7WG1/8=
In-Reply-To: <slrnuq8920.7hv.jj@iridium.wf32df>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sun, 14 Jan 2024 18:49 UTC

On 14.01.2024 19:13, Jim Jackson wrote:
>
> This works for me. It's the stripped down version of a couple of scripts
> I use every login session ...

It indeed looks good; I can retrieve the history entries with the arrow
up/down keys, then navigate with the arrow left/right keys (and also
with the Vi keys), I can even issue Vi commands, etc. - Nice. - Thanks.

Janis

> #!/bin/bash
>
> HISTFILE=$HOME/.history.test
> HISTNUM=200
>
> while $loop ; do
> echo
> set -H -o history
> history -r
> read -p "prompt : " -e ans
> echo "$ans" >> $HISTFILE
> case "$ans" in
> q|quit|Q|Quit|QUIT)
> exit 0
> ;;
> esac
> done
>
>
> HTH
> Jim
>

Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a read-loop ?)

<slrnuq8abn.110.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7605&group=comp.unix.shell#7605

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.samoylyk.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: What you talkin' 'bout??? (Was: [ksh] Readline support in a
read-loop ?)
Date: Sun, 14 Jan 2024 18:35:35 -0000 (UTC)
Message-ID: <slrnuq8abn.110.naddy@lorvorc.mips.inka.de>
References: <untn92$3t3gn$1@dont-email.me>
<slrnuq546h.20hn.naddy@lorvorc.mips.inka.de>
<unu848$201hg$1@news.xmission.com>
<slrnuq5c60.24t9.naddy@lorvorc.mips.inka.de> <unvdd8$5i0p$1@dont-email.me>
<slrnuq7qmg.2tbp.naddy@lorvorc.mips.inka.de>
<slrnuq8920.7hv.jj@iridium.wf32df>
Injection-Date: Sun, 14 Jan 2024 18:35:35 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="1057"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Sun, 14 Jan 2024 18:35 UTC

On 2024-01-14, Jim Jackson <jj@franjam.org.uk> wrote:

> This works for me. It's the stripped down version of a couple of scripts
> I use every login session ...
>
> #!/bin/bash
>
> HISTFILE=$HOME/.history.test
> HISTNUM=200
>
> while $loop ; do
> echo
> set -H -o history

Oh! That's better. We can enable history in a non-interactive
shell and push input lines into the history:

#!/usr/local/bin/bash
set -o history
while IFS= read -r -e -p "prompt> " line
do
echo "[$line]"
history -s "$line"
done

That's the bash solution to Janis's original problem.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor