From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 21210bd0 for ; Sat, 8 Feb 2020 23:36:08 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 786249CCB4; Sun, 9 Feb 2020 09:36:07 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id D46309CCAA; Sun, 9 Feb 2020 09:35:33 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bsdimp-com.20150623.gappssmtp.com header.i=@bsdimp-com.20150623.gappssmtp.com header.b="OONbWaNw"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 232489CCAA; Sun, 9 Feb 2020 09:35:32 +1000 (AEST) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by minnie.tuhs.org (Postfix) with ESMTPS id 48C6E9CCA9 for ; Sun, 9 Feb 2020 09:35:31 +1000 (AEST) Received: by mail-qt1-f178.google.com with SMTP id r5so1035262qtt.9 for ; Sat, 08 Feb 2020 15:35:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=woIuBFN8s+WGYlg6JkDzdl6Ucr0DZPxb2B3C1np9PzE=; b=OONbWaNwkP2cSeNz4whBbAx4NzAN0ghcQEmw4gXUMs2WSsowIZdnf/i/n4L6RhDik+ nn1QC/UoKaPZWvhgGy7j92tWosRB0V8kOiGKz282Ssdi1DuN7Kr1TRhUPLI4x9KtozSP 52wZJaaqRn3k8AB9zrgBWRYxIk7srzIW5pV5HCg+QY1+t+BbD84bjJ44ieMhobvsg8Ac E0Rb5HkkWSyBTIs8O3bl8kGRvz09AhtyYiN3csOx0EGU5IxVe/8TpC6po8V1h2q50sIu ZG7UT3q1i/mgRgVj012P1ZPnDMmCjzh2r81uYGrJmshvo3BSRzF1LxvmsNExQup/ieVw F7tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=woIuBFN8s+WGYlg6JkDzdl6Ucr0DZPxb2B3C1np9PzE=; b=ByRVAq+1uHpL2h01Hq0iA3bnNersqZsxBJvbKuRPd0BYLNkUBlOk75nQflV3RDeNqY Zo5aY5vWttSCgtofQw8kuXNXR2ojlD+qojut0/ryWRt6ekrH4P/CQ47OYifVKfSMsbvJ nnN1mREzZTtWinIhdOUCiUhGtPsyhBFeiEh/goEjRvsHJWyErAVYiTBMWTPV/YLF++T5 LBGX6O8xSn9jJNBfWynyufnh6QF5LK1fZH4V+/pWgcX7vScYlw2q0b/kMQEIy3fgIYCP q3Nw0mkOtIKfZ3KwWuiLrssdJGF15uMN1gwwn7pp7+2a+w+H78CiXHdvy2p6xApnJL1o xgeg== X-Gm-Message-State: APjAAAW8/WLbWyfTjfBAWRTtZAFsRl/gEIzbXzExhev5iwxXEowHF1X4 CCNSVR3dRQg4vL/MmxKFd4Mpald2h9lqIQn+ZO30dw== X-Google-Smtp-Source: APXvYqwXXL3NP7cXspsLI0xJz7S2T7Vgf2YHkssHfJmFIMR6XnmFpeeyP0Dr3ZERLsRIijPFH9DVHynfPYSBIIFmffo= X-Received: by 2002:ac8:78c:: with SMTP id l12mr4426856qth.187.1581204930387; Sat, 08 Feb 2020 15:35:30 -0800 (PST) MIME-Version: 1.0 References: <46c41c18-5b44-14e5-1f0a-9272866993da@case.edu> <62548c3e-4692-c2d3-f06f-745353490b95@case.edu> In-Reply-To: From: Warner Losh Date: Sat, 8 Feb 2020 16:35:18 -0700 Message-ID: To: Rob Pike Content-Type: multipart/alternative; boundary="00000000000031783e059e18f655" Subject: Re: [TUHS] Warner's Early Unix Presentation X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --00000000000031783e059e18f655 Content-Type: text/plain; charset="UTF-8" On Sat, Feb 8, 2020, 4:29 PM Rob Pike 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 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@case.edu http://tiswww.cwru.edu/~chet/ >> > --00000000000031783e059e18f655 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


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

% rc

% whatis cd

builtin cd

%=C2=A0


= 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 loo= sely) world, the phrase "free of decoration" is apostasy.=C2=A0


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

Warner=C2=A0

-rob=



On Sun, Feb 9,= 2020 at 10:26 AM Chet Ramey <chet.ramey@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() {
>
> =C2=A0 =C2=A0 echo hi
>
> =C2=A0 =C2=A0 }
>
> 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 `buil= tin'
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 c= ould
> 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 ()
{
=C2=A0 =C2=A0 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
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0``Ars longa, = vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU=C2=A0 =C2=A0 chet@case.edu=C2=A0 =C2=A0 http://tiswww.cwru.edu/~chet/
--00000000000031783e059e18f655--