The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Chet Ramey <chet.ramey@case.edu>
To: Adam Thornton <athornton@gmail.com>,
	The Eunuchs Hysterical Society <tuhs@tuhs.org>
Subject: Re: [TUHS] Shell builtin exec
Date: Tue, 20 Aug 2019 20:38:08 -0400	[thread overview]
Message-ID: <83aa800b-76e8-7d72-8f1b-2148e36eec05@case.edu> (raw)
In-Reply-To: <CAP2nic1SEFg=e4htyw_23KAL_pUC98JL4XDoWLKwU365BMWXxg@mail.gmail.com>

On 8/20/19 5:10 PM, Adam Thornton wrote:
> This is probably the place to ask:
> 
> I understand why the shell builtin "exec" is the same as the syscall exec()
> in the sense of "replace this process with that one."  But why is it also
> the way to redirect filehandles in the current shell?  (That is, why isn't
> the redirection named something else?)

It was probably a side effect that turned out to be useful. The `exec'
builtin performs redirections without a way to undo them, because why
bother, and executes its arguments as a command with arguments, as if it
were in a child process.

The original Bourne shell just performed the redirections and returned
if there weren't any arguments, leaving the non-undoable redirections
in place.

-- 
``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/

      parent reply	other threads:[~2019-08-21  0:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 21:10 Adam Thornton
2019-08-20 22:00 ` Warren Toomey
2019-08-21  0:38 ` Chet Ramey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83aa800b-76e8-7d72-8f1b-2148e36eec05@case.edu \
    --to=chet.ramey@case.edu \
    --cc=athornton@gmail.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).