Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #402: Secretary sent chain letter to all 5000 employees.


comp / comp.unix.shell / Re: [ksh93] defunct 'fc' command?

SubjectAuthor
* [ksh93] defunct 'fc' command?Janis Papanagnou
`* Re: [ksh93] defunct 'fc' command?Geoff Clare
 `* Re: [ksh93] defunct 'fc' command?Janis Papanagnou
  `* Re: [ksh93] defunct 'fc' command?Geoff Clare
   `- Re: [ksh93] defunct 'fc' command?Janis Papanagnou

1
Subject: [ksh93] defunct 'fc' command?
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 1 Jul 2024 09:03 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: [ksh93] defunct 'fc' command?
Date: Mon, 1 Jul 2024 11:03:17 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <v5trcn$10nuj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 01 Jul 2024 11:03:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="97c7a9a36948d3f0df5e998339a9ced9";
logging-data="1073107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/z4dnhRquc9rIZ56f/XJbM"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:rMRB3RCfr2np+bNKwrfXkVltT0k=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
View all headers

In a recent thread about an emacs mode editing mode function in ksh
there was a note about ^O ("it will stay in the history and move to
the next line"). Thinking about an emulation in vi editing mode I
noticed that 'fc' doesn't seem to work on my Limux platform (neither
with ksh93u+ nor with ksh93u+m). Usually I use that built-in command
only as 'fc -l' (to list the history entries), and omitting the '-l'
should execute these commands. Alas, 'fc <from> <to>' doesn't work;
for example

$ fc -l 1013 1015
1013 ls X
1014 ls Y
1015 ls Z
$ fc 1013 1015
15
^C
? ^Z[1] + Stopped fc 1013 1015
$ kill %%
[1] + Terminated fc 1013 1015

Is that an issue in my environment (or on my platform), or a bug?

Janis

Subject: Re: [ksh93] defunct 'fc' command?
From: Geoff Clare
Newsgroups: comp.unix.shell
Date: Mon, 1 Jul 2024 13:00 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: [ksh93] defunct 'fc' command?
Date: Mon, 1 Jul 2024 14:00:13 +0100
Lines: 40
Message-ID: <trlalk-d5q.ln1@ID-313840.user.individual.net>
References: <v5trcn$10nuj$1@dont-email.me>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net MfpXSyQwHuXw8WpC665UhQHyRyehCarRk0OxVVCjirPAot8SS/
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:grpAfqfZQKy/yqO92kcgTj/ckRQ= sha256:wlSFLaSWVEpxcCJAm9Ts9Rwbk7XF2wDKzipp3T2c+Y4=
User-Agent: Pan/0.154 (Izium; 517acf4)
View all headers

Janis Papanagnou wrote:

> I noticed that 'fc' doesn't seem to work on my Limux platform (neither
> with ksh93u+ nor with ksh93u+m). Usually I use that built-in command
> only as 'fc -l' (to list the history entries), and omitting the '-l'
> should execute these commands. Alas, 'fc <from> <to>' doesn't work;
> for example
>
> $ fc -l 1013 1015
> 1013 ls X
> 1014 ls Y
> 1015 ls Z
> $ fc 1013 1015
> 15
> ^C
> ?
> ^Z[1] + Stopped fc 1013 1015
> $ kill %%
> [1] + Terminated fc 1013 1015
>
>
> Is that an issue in my environment (or on my platform), or a bug?

It's an issue with your expectation. By default, fc starts an editor.
Presumably you don't have FCEDIT set, as your output shows the default
editor (ed) was used; it was ed that wrote the "15" and the "?".

If you just want the commands executed, you can specify an editor
that does nothing:

fc -e true 1013 1015
fc -e : 1013 1015

Or, if you only want to execute one command, you can use -s (without
specifying a substitution).

This is all POSIX standard stuff.

--
Geoff Clare <netnews@gclare.org.uk>

Subject: Re: [ksh93] defunct 'fc' command?
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 1 Jul 2024 15:54 UTC
References: 1 2
Path: 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: [ksh93] defunct 'fc' command?
Date: Mon, 1 Jul 2024 17:54:18 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <v5ujfb$152jc$1@dont-email.me>
References: <v5trcn$10nuj$1@dont-email.me>
<trlalk-d5q.ln1@ID-313840.user.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 01 Jul 2024 17:54:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3aae311a4b7fe653baf8e036cd83fc5e";
logging-data="1215084"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Fc9uMbCAKrRWzS0eC6vXQ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LLs0NgflpLAdQSqQce8AILqOfOE=
In-Reply-To: <trlalk-d5q.ln1@ID-313840.user.individual.net>
X-Enigmail-Draft-Status: N1110
View all headers

On 01.07.2024 15:00, Geoff Clare wrote:
> Janis Papanagnou wrote:
>
>> I noticed that 'fc' doesn't seem to work on my Limux platform (neither
>> with ksh93u+ nor with ksh93u+m). Usually I use that built-in command
>> only as 'fc -l' (to list the history entries), and omitting the '-l'
>> should execute these commands. Alas, 'fc <from> <to>' doesn't work;
>> for example
>>
>> $ fc -l 1013 1015
>> 1013 ls X
>> 1014 ls Y
>> 1015 ls Z
>> $ fc 1013 1015
>> 15
>> ^C
>> ?
>> ^Z[1] + Stopped fc 1013 1015
>> $ kill %%
>> [1] + Terminated fc 1013 1015
>>
>>
>> Is that an issue in my environment (or on my platform), or a bug?
>
> It's an issue with your expectation.

(Actually my [inappropriate] environment setting; see below.)

> By default, fc starts an editor.
> Presumably you don't have FCEDIT set, as your output shows the default
> editor (ed) was used; it was ed that wrote the "15" and the "?".

Argh! - Yes, you are right. I was confident that I had a sensible
definition, but I see that FCEDIT=/bin/ed and it didn't appear
to me that what I got was an 'ed' prompt. - Thanks!

>
> If you just want the commands executed, you can specify an editor
> that does nothing:
>
> fc -e true 1013 1015
> fc -e : 1013 1015

This is a nice code pattern.

>
> Or, if you only want to execute one command, you can use -s (without
> specifying a substitution).

I had tried this before and got an inconsistent error message (-e
instead of -s) when [inappropriately] trying for a range

$ fc -s 1071 1073
ksh: fc: -e - requires single argument

so I haven't followed that path further.

>
> This is all POSIX standard stuff.

Janis

Subject: Re: [ksh93] defunct 'fc' command?
From: Geoff Clare
Newsgroups: comp.unix.shell
Date: Tue, 2 Jul 2024 12:50 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: [ksh93] defunct 'fc' command?
Date: Tue, 2 Jul 2024 13:50:29 +0100
Lines: 41
Message-ID: <ll9dlk-son.ln1@ID-313840.user.individual.net>
References: <v5trcn$10nuj$1@dont-email.me>
<trlalk-d5q.ln1@ID-313840.user.individual.net>
<v5ujfb$152jc$1@dont-email.me>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net uFsa7OlPP+ZQxEQe02vPqgJl7qKqGDr18RSnH23wfe0XBgTIqp
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:OywO7FoesUTPX7fu2LhCEBSv2VI= sha256:yvsLsfHxtu2uIVHWpMhjAJ83u27y2MK/sypStbEQW88=
User-Agent: Pan/0.154 (Izium; 517acf4)
View all headers

Janis Papanagnou wrote:

> On 01.07.2024 15:00, Geoff Clare wrote:
>>
>> If you just want the commands executed, you can specify an editor
>> that does nothing:
>>
>> fc -e true 1013 1015
>> fc -e : 1013 1015
>
> This is a nice code pattern.
>
>>
>> Or, if you only want to execute one command, you can use -s (without
>> specifying a substitution).
>
> I had tried this before and got an inconsistent error message (-e
> instead of -s) when [inappropriately] trying for a range
>
> $ fc -s 1071 1073
> ksh: fc: -e - requires single argument
>
> so I haven't followed that path further.

Yes, you can't give a range with -s (which is why I wrote "if you only
want to execute one command" above).

Looks like ksh implements -s by pretending that "-e -" was specified,
but the output from "--help" implies the relationship is the other way
round:

OPTIONS
-e editor editor specifies the editor to use to edit the history
command. A value of - for editor is equivalent to
specifying the -s option.

It would make more sense for the code to do it that way too, since -s is
in POSIX but "-e -" isn't.

--
Geoff Clare <netnews@gclare.org.uk>

Subject: Re: [ksh93] defunct 'fc' command?
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 16:02 UTC
References: 1 2 3 4
Path: 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: [ksh93] defunct 'fc' command?
Date: Tue, 2 Jul 2024 18:02:19 +0200
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <v618ac$1mvae$1@dont-email.me>
References: <v5trcn$10nuj$1@dont-email.me>
<trlalk-d5q.ln1@ID-313840.user.individual.net> <v5ujfb$152jc$1@dont-email.me>
<ll9dlk-son.ln1@ID-313840.user.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 02 Jul 2024 18:02:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c19e6dc780aa23a8211f691d80a37f31";
logging-data="1801550"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UZj0qx9xZ9msg7+u2jRad"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:X3COVO0aOTlwUFQXvcZZCaQTbuE=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <ll9dlk-son.ln1@ID-313840.user.individual.net>
View all headers

On 02.07.2024 14:50, Geoff Clare wrote:
>>>
>>> Or, if you only want to execute one command, you can use -s (without
>>> specifying a substitution).
>>
>> I had tried this before and got an inconsistent error message (-e
>> instead of -s) when [inappropriately] trying for a range
>>
>> $ fc -s 1071 1073
>> ksh: fc: -e - requires single argument
>>
>> so I haven't followed that path further.
>
> Yes, you can't give a range with -s (which is why I wrote "if you only
> want to execute one command" above).

Yes, sure. - Above I've just described the experiments I've done
before your post (and even before I've written my original post
here). - It was no disrespect, just your post came too late. :-)
What I tried to say above was that I tried -s and that the error
message -e contributed to my impression that something is spoiled,
thus me not following this specific trial.

Actually, with my original intention to emulate the Emacs-mode ^O
function in Vi-mode I haven't spent any more time. My impression
is that it's a function that should be supported as shell builtin.
It seems to not make sense trying KEYDB traps or grep'ing the
${HISTFILE} contents (just to name two thoughts I pondered about).

Wasn't there some callback facility (maybe also through discipline
functions) to obtain and manipulate an entered command line before
it gets evaluated? (I thought to recall something like that. If so
it might be a way to more easily get the desired function working.
Must have a look... - but not now.)

Janis

1

rocksolid light 0.9.8
clearnet tor