Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14570

Re: History of bash's support for self-modifying shell scripts?

From Robert Elz <kre@munnari.OZ.AU>
Newsgroups gnu.bash.bug
Subject Re: History of bash's support for self-modifying shell scripts?
Date 2018-09-11 10:19 +0700
Message-ID <mailman.621.1536636010.1284.bug-bash@gnu.org> (permalink)
References <1536621101.1095.13.camel@16bits.net> <20180910052543.GA4482@localhost>

Show all headers | View raw


    Date:        Tue, 11 Sep 2018 01:11:41 +0200
    From:        =?ISO-8859-1?Q?=C1ngel?= <angel@16bits.net>
    Message-ID:  <1536621101.1095.13.camel@16bits.net>

  | The Thompson shell (up to Sixth Edition UNIX) supported a goto command
  | that was implemented as an external command(!) that moved the
  | filepointer to the label location (marked by the : command).

What is probably more important here is that in that shell, the script was 
standard input (always, whether it was a file as in "sh file" or just the
original stdin (often a tty) from "sh") and all foreground commands
inherited that standard input when invoked, unless redirected.
(Yes, just running "cat" without args was a way to send the rest of
the script to stdout, and then have the shell exit because it reached EOF.)

Any command could reposition the shell's stdin, which made it possible
to do all kinds of "interesting things".

On the other hand, it was impossible to pipe the output of some other
command into a script
	ls ^ sh file
would not work (note the use of the v6 "pipe" character...) as the sh
running the script simply closed its stdin and replaced it with the file.
Redirecting stdin ("sh file < whatever") was also ineffective.

These days there is no syntax to refer to the script itself - it is impossible
to explicitly pass the script to a command to access - the only time any
of this is still relevant is when the shell's input is from stdin (sh -s,
whether the -s is explicit or implied from the (lack of) other args).

kre

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: History of bash's support for self-modifying shell scripts? Robert Elz <kre@munnari.OZ.AU> - 2018-09-11 10:19 +0700

csiph-web