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


Groups > gnu.bash.bug > #14566

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

From Josh Triplett <josh@joshtriplett.org>
Newsgroups gnu.bash.bug
Subject History of bash's support for self-modifying shell scripts?
Date 2018-09-09 22:25 -0700
Message-ID <mailman.596.1536588324.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


While digging into the details of how bash reads shell scripts, I found
some indications that bash goes out of its way to support self-modifying
shell scripts. As far as I can tell, after reading and executing each
command, bash will seek backward and re-read the script from the
byte after the end of that command, rather than executing out of
buffered data previously read from the file. (For the purposes of this
logic, compound commands get run as a single unit, and this logic kicks
in after running the full compound command.)

I haven't found any indications that POSIX or similar require this, and
other shells like dash don't have the same behavior. I also haven't
found any details about this in the bash changelog or version control
history.

I'd like to get some more information on the history of this mechanism,
if possible. What led to bash adding support for this? What version of
bash first incorporated this, and has it changed over time?

(I don't want to use this mechanism myself; I'm asking because I'm
working on a project that needs to care about various shells'
compatibility requirements, and I wanted to find out more about this
unusual corner case.)

Thanks,
Josh Triplett

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


Thread

History of bash's support for self-modifying shell scripts? Josh Triplett <josh@joshtriplett.org> - 2018-09-09 22:25 -0700

csiph-web