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


Groups > gnu.bash.bug > #14566 > unrolled thread

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

Started byJosh Triplett <josh@joshtriplett.org>
First post2018-09-09 22:25 -0700
Last post2018-09-09 22:25 -0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

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

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

FromJosh Triplett <josh@joshtriplett.org>
Date2018-09-09 22:25 -0700
SubjectHistory of bash's support for self-modifying shell scripts?
Message-ID<mailman.596.1536588324.1284.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web