I figured it out. Turns out PS1 wasn't set. Interesting how this impacts interactive process fork behavior (maybe it runs some things the way non-interactive processes would normally be launched)?
============================================================ Matthew Giassa, MASc, BASc, EIT Security and Embedded Systems Specialist linkedin: https://ca.linkedin.com/in/giassa e-mail: matt...@giassa.net website: www.giassa.net > -------- Original Message -------- > Subject: Forcing builtins (interactive, non-interactive shells) to > execute in fork()'ed process. > From: "Matthew Giassa" <matt...@giassa.net> > Date: Wed, October 26, 2016 3:00 pm > To: bug-bash@gnu.org > Cc: help-b...@gnu.org > > > I'm doing some testing with an on-screen colorizer library I wrote, > which does > some PTY manipulation, captures screen output, and renders certain regex > patterns in certain colors. It's designed to help testers notice certain > keywords in a test environment that is not easily automated. > > On bash 4.3.36 on Ubuntu 16.04 LTS, I've noticed that all commands seem > to > fork() a separate process, even shell builtins. This makes it easy to > detect > the start of any command by hooking fork() in libc. However, on bash > 4.3.11 on > Ubuntu 14.04 LTS, this behavior is not observed (ie: only "disk > commands" cause > a fork(), while builtins do not trigger a fork). Additionally, when > running in a > non-interactive bash instance, shell builtins never cause a fork, > regardless of > whether I'm running a script (ie: ./test.sh), or using bash via the "-c" > option > (ie: bash -c "ls; ls -la"). > > Is there any way, either via environment variables, BASHRC settings, or > bash > startup flags, or some other means (ie: not recompiling bash) where I > can: > > 1) Have bash 4.3.11 fork() for every interactive command, like in bash > 4.3.36. > 2) Have both bash 4.3.11 and 4.3.36 trigger a fork() for builtins being > executed > in a non-interactive shell? > > I could potentially use PROMPT_COMMAND to detect the most recent > command, "type" > it, and force running in a subshell, but I want to avoid breaking other > scripts > by changing how commands are actually executed, save for forking. > > On a side note, its interesting how bash 4.3.36 does this, even for the > "cd" > command, since launching it in a subshell can't change the CWD for the > parent > process. > > Thank you. > > > > ============================================================ > Matthew Giassa, MASc, BASc, EIT > Security and Embedded Systems Specialist > e-mail: matt...@giassa.net > website: www.giassa.net