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

Dan Mack mack at macktronics.com
Tue Oct 31 14:49:30 UTC 2017


Devin Teske <devin at shxd.cx> writes:

>> 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.

                            ^^ i use '!$' constantly to pull up the last
                            argument to the previous command

Definately appreciate your perspective.  My lack of doing this the bash
way is really just a side effect of being an early tcsh user, bash not
being everywhere I needed it, habbit, and prefix thinking with respect
to searching command history.

Dan










More information about the svn-src-all mailing list