[OT] Re: how to start in "overwrite-mode"

View: New views
10 Messages — Rating Filter:   Alert me  

Parent Message unknown [OT] Re: how to start in "overwrite-mode"

by Stephane Chazelas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009-10-27, 16:29(-04), Jim Lawson:
[...]

> I have a user we're trying to encourage to migrate from tcsh to bash,
> who is used to his shell starting up in overwrite mode (as opposed to
> the default Insert mode.)
>
> Long story short, while I can easily bind a key to the "overwrite-mode"
> readline function, I can't figure out how to make bind start up that way
> as I can't find an "overwrite" readline variable which I can manipulate.
>  And the user doesn't want to hit "Ins" every time he starts a shell.
>
> Anyone know how to do this?
[...]

Sorry, I don't know how to do it with bash, but here's a
solution for zsh (switching from tcsh to zsh might reveal
easier btw):

in ~/.zshrc, add:

zle-line-init() zle overwrite-mode
zle -N zle-line-init

To get back on topic, bash is the only Bourne-like shell that I
know that doesn't allow that function definition syntax above,
I've always wondered why.

--
Stéphane

Re: [OT] Re: how to start in "overwrite-mode"

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> zle-line-init() zle overwrite-mode
> zle -N zle-line-init
>
> To get back on topic, bash is the only Bourne-like shell that I
> know that doesn't allow that function definition syntax above,
> I've always wondered why.

The Posix grammar has never allowed it (a `function_body' must be a
compound command, and that's what bash implements), and there has
never been sufficient demand to add it as an extension.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Re: [OT] Re: how to start in "overwrite-mode"

by Stephane Chazelas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009-10-28 09:00:59 -0400, Chet Ramey:

> > zle-line-init() zle overwrite-mode
> > zle -N zle-line-init
> >
> > To get back on topic, bash is the only Bourne-like shell that I
> > know that doesn't allow that function definition syntax above,
> > I've always wondered why.
>
> The Posix grammar has never allowed it (a `function_body' must be a
> compound command, and that's what bash implements), and there has
> never been sufficient demand to add it as an extension.
[...]

It's never allowed it to POSIX _scripts_, but it won't make a
shell non-conformant to support it (and ksh, pdksh, ash, zsh
even posh all do support it), just like most POSIX conformant
shells support arrays for instance even though that's not a
POSIX feature.

bash not supporting it helps for writing POSIX compliant scripts
(as it will return an error if one tries to use that
non-standard feature), but as bash is the only POSIX shell that
doesn't support it, it feels a bit silly.

I wonder what's the rationale for POSIX not supporting it (is it
because of bash?).

--
Stephane



Re: [OT] Re: how to start in "overwrite-mode"

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stephane CHAZELAS wrote:

> 2009-10-28 09:00:59 -0400, Chet Ramey:
>>> zle-line-init() zle overwrite-mode
>>> zle -N zle-line-init
>>>
>>> To get back on topic, bash is the only Bourne-like shell that I
>>> know that doesn't allow that function definition syntax above,
>>> I've always wondered why.
>> The Posix grammar has never allowed it (a `function_body' must be a
>> compound command, and that's what bash implements), and there has
>> never been sufficient demand to add it as an extension.
> [...]
>
> It's never allowed it to POSIX _scripts_, but it won't make a
> shell non-conformant to support it (and ksh, pdksh, ash, zsh
> even posh all do support it), just like most POSIX conformant
> shells support arrays for instance even though that's not a
> POSIX feature.

That's why I said it would be added as an extension.

> bash not supporting it helps for writing POSIX compliant scripts
> (as it will return an error if one tries to use that
> non-standard feature), but as bash is the only POSIX shell that
> doesn't support it, it feels a bit silly.

"Silly" it may be, but there's not really the demand for it.

> I wonder what's the rationale for POSIX not supporting it (is it
> because of bash?).

That would be the tail wagging the dog, wouldn't it?  It's never been
in the grammar.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Re: [OT] Re: how to start in "overwrite-mode"

by Stephane Chazelas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009-10-28 09:46:49 -0400, Chet Ramey:
[...]

> >> The Posix grammar has never allowed it (a `function_body' must be a
> >> compound command, and that's what bash implements), and there has
> >> never been sufficient demand to add it as an extension.
> > [...]
> >
> > It's never allowed it to POSIX _scripts_, but it won't make a
> > shell non-conformant to support it (and ksh, pdksh, ash, zsh
> > even posh all do support it), just like most POSIX conformant
> > shells support arrays for instance even though that's not a
> > POSIX feature.
>
> That's why I said it would be added as an extension.

Sorry, I overlooked that bit.

> > bash not supporting it helps for writing POSIX compliant scripts
> > (as it will return an error if one tries to use that
> > non-standard feature), but as bash is the only POSIX shell that
> > doesn't support it, it feels a bit silly.
>
> "Silly" it may be, but there's not really the demand for it.

I can understand it. I was more curious about the origins. After
all, that breaks Bourne backward compatibility (in a shell
called Bourne-again shell)) and it seems more effort to exclude
one form of command rather than include any form of command.

f() for i in 1; do echo test; done
f() { echo test; } > xx

are allowed (and I doubt there has been a lot of demand for
that), and can be confusing all the same (the second one for
instance is not interpreted POSIXly by zsh).

> > I wonder what's the rationale for POSIX not supporting it (is it
> > because of bash?).
>
> That would be the tail wagging the dog, wouldn't it?  It's never been
> in the grammar.

OK, but again, why exclude simple commands here? Would there be
some implication? Has there be historical versions of sh that
didn't support it?

I guess I should ask the question on the POSIX list.

Cheers,
Stephane



Re: [OT] Re: how to start in "overwrite-mode"

by Greg Wooledge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote:
> I can understand it. I was more curious about the origins. After
> all, that breaks Bourne backward compatibility (in a shell
> called Bourne-again shell)

Bourne shell has no functions at all.

> Has there be historical versions of sh that
> didn't support it?

Bourne shell on Ultrix and (I believe still to this day) Sun Solaris.
No functions at all.  None.



Re: [OT] Re: how to start in "overwrite-mode"

by Chris F.A. Johnson-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 28 Oct 2009, Greg Wooledge wrote:

> On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote:
> > I can understand it. I was more curious about the origins. After
> > all, that breaks Bourne backward compatibility (in a shell
> > called Bourne-again shell)
>
> Bourne shell has no functions at all.

   Had. Only before 1984. Since then it has had functions.

   The first shell I used, the Bourne shell on AT&T SVR3.2, had
   functions.

--
   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)



Re: [OT] Re: how to start in "overwrite-mode"

by Stephane Chazelas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009-10-28 11:06:09 -0400, Chris F.A. Johnson:

> On Wed, 28 Oct 2009, Greg Wooledge wrote:
>
> > On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote:
> > > I can understand it. I was more curious about the origins. After
> > > all, that breaks Bourne backward compatibility (in a shell
> > > called Bourne-again shell)
> >
> > Bourne shell has no functions at all.
>
>    Had. Only before 1984. Since then it has had functions.
>
>    The first shell I used, the Bourne shell on AT&T SVR3.2, had
>    functions.
[...]

Yes,

The best place for information on the Bourne shell IMO is
http://www.in-ulm.de/~mascheck/bourne/index.html

Where we learn that Solaris (well SunOS at the time) sh has had
functions since SunOS 3, which according to
http://www.levenez.com/unix/ (another great site about Unix
history) takes us back to early 1986.

--
Stephane



Re: [OT] Re: how to start in "overwrite-mode"

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stephane CHAZELAS wrote:

> 2009-10-28 11:06:09 -0400, Chris F.A. Johnson:
>> On Wed, 28 Oct 2009, Greg Wooledge wrote:
>>
>>> On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote:
>>>> I can understand it. I was more curious about the origins. After
>>>> all, that breaks Bourne backward compatibility (in a shell
>>>> called Bourne-again shell)
>>> Bourne shell has no functions at all.
>>    Had. Only before 1984. Since then it has had functions.
>>
>>    The first shell I used, the Bourne shell on AT&T SVR3.2, had
>>    functions.
> [...]
>
> Yes,
>
> The best place for information on the Bourne shell IMO is
> http://www.in-ulm.de/~mascheck/bourne/index.html
>
> Where we learn that Solaris (well SunOS at the time) sh has had
> functions since SunOS 3, which according to
> http://www.levenez.com/unix/ (another great site about Unix
> history) takes us back to early 1986.

Functions were the last thing added to sh by Steve Bourne before he
left Bell Labs (he finished in 1983) and first appeared in the SVR2
shell (1984).

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Re: [OT] Re: how to start in "overwrite-mode"

by Marc Herbert-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chet Ramey a écrit :
> Functions were the last thing added to sh by Steve Bourne before he
> left Bell Labs (he finished in 1983)

From Steve Bourne himself:
<http://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh?pp=3>

(very interesting interview)