svn commit: r325092 - head/usr.bin/fortune/datfiles

Devin Teske devin at shxd.cx
Tue Oct 31 04:33:38 UTC 2017


> On Oct 30, 2017, at 2:35 PM, Dan Mack <mack at macktronics.com> wrote:
> 
> Devin Teske <devin at shxd.cx> writes:
> 
>> Better in bash which allows you to filter not only on "begins with"
>> but also "contains" (which is arguably more valuable than "begins
>> with").
> 
> Definately different. Better?

Typical session of editing exim acls on the mail server:

1. Log in via ssh to bash
2. Esc-P vi ENTER
(pulls up "sudo vi /usr/local/etc/exim/acls/relay_domains")
3. ENTER
4. Make changes in vi, save, exit
5. Esc-P restart ENTER
(pulls up "sudo service exim restart")
6. ENTER

Ok, so if I was using tcsh, I cannot call this "better":

1. Log in via ssh to tcsh
2. sudo vi Esc-P
(pulls up "sudo vi /usr/local/etc/exim/acls/relay_domains")
3. ENTER
4. Make changes in vi, save, exit
5. sudo service exim r Esc-P
(pulls up "sudo service exim restart")
6. ENTER

As you can see, being able to match on contents rather than begins-with saves me valuable keystrokes and allows me to find history elements faster with less effort.

Take the example of using "service". Imagine:

1. Esc-P restart
2. Esc-P stop
3. Esc-P reloas

Etc.

Using the tcsh implementation you simply cannot navigate the history sequentially like that.

However... there is the fallback of history substitution to pluck elements in tcsh which also works in bash:

!?text?:p

This will copy the most recent history element containing "text" onto the top of the history.

In bash you can turn on histverify (using shopt) which will allow you to use simply "!?text" (without quotes) to pull up the previous command containing "text". In tcsh and zsh -- which lack the histverify shell option -- the syntax "!?text" will still work but without the "?:p" modifier will execute the match right away.

However, this cross-shell history substitution feature does not allow matching on "begins-with", only "contains," and as-such is not as flexible as bash's Esc-[PN] feature.

Though, I admittedly use history expansion a lot too.
-- 
Devin




More information about the svn-src-all mailing list