[TUHS] Warner's Early Unix Presentation

Warner Losh imp at bsdimp.com
Sun Feb 9 09:35:18 AEST 2020


On Sat, Feb 8, 2020, 4:29 PM Rob Pike <robpike at gmail.com> wrote:

> % rc
>
> % whatis cd
>
> builtin cd
>
> %
>
>
> It's much simpler this way. The output is the executable input, free of
> decoration and ready to use.
>
>
> In today's Unix (I use the term loosely) world, the phrase "free of
> decoration" is apostasy.
>

A number of utilities have a special flag to use in shell scripts to remove
the decorations. I both like and loath this design pattern.

Warner

-rob
>
>
>
> On Sun, Feb 9, 2020 at 10:26 AM Chet Ramey <chet.ramey at case.edu> wrote:
>
>> On 2/8/20 6:11 PM, Rob Pike wrote:
>> > Not for me it doesn't.
>> >
>> > % bash
>> >
>> > bash-3.2$ function f() {
>> >
>> >     echo hi
>> >
>> >     }
>> >
>> > bash-3.2$ export f
>> > bash-3.2$ bash
>> > bash-3.2$ f
>> > bash-3.2$
>>
>> jenna(1)$ echo $BASH_VERSION
>> 5.0.11(6)-release
>> jenna(1)$ f() { echo f; }
>> jenna(1)$ export -f f
>> jenna(1)$ bash
>> jenna(2)$ f
>> f
>> jenna(2)$
>>
>> It works the same in Mac OS X's bash-3.2.
>>
>> > I added the 'builtin' command, which did leave the labs. But I added it
>> as
>> > a way for the "whatis" command to show a builtin, as well as allowing a
>> way
>> > to guarantee you get the builtin on execution.
>>
>> Bash uses `type' to tell whether something is a builtin. How does
>> `builtin'
>> say whether or not a command is builtin? The output with no arguments?
>>
>> > How do I get bash to print the function as (shell) source code, so I
>> could
>> > edit it and play with it again? It was the synergy of all this stuff
>> > connected seamlessly that made it so compelling.
>> >
>>
>> jenna(2)$ declare -pf f
>> f ()
>> {
>>     echo f
>> }
>> declare -fx f
>>
>> If it weren't exported, you wouldn't get the `declare' command appended
>> there.
>>
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                  ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, UTech, CWRU    chet at case.edu    http://tiswww.cwru.edu/~chet/
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20200208/3d58c9d4/attachment.html>


More information about the TUHS mailing list