On 6/27/11 11:28 AM, todd.mil...@courtesan.com wrote: > Machine Type: x86_64-unknown-openbsd4.9 > > Bash Version: 4.2 > Patch Level: 10 > Release Status: release > > Description: > Newer versions of bash appear to ignore the '-' in argv[0] > when the "-c" option is specified. That is, for: > char *argv[] = { "-bash", "-c", "id", NULL }; > bash used to run as a login shell and source .bash_profile. > I've verified that bash 3.00.15 behaves as expected but > bash 3.2 and 4.2 require that the "-l" option be specified > even though argv[0] indicates that it should be a login > shell. Is this change in historical behavior intentional?
Yes. It's a compile-time option (NON_INTERACTIVE_LOGIN_SHELLS, which is off by default) and has been that way for almost 15 years. The change log says that option was added before bash-2.02; the code is the same in bash-3.0. The thinking was that allowing non-interactive login shells that sourced startup files intended to be run when interactive (e.g., .bash_profile) caused more harm than good, and that non-interactive shells shouldn't be running any startup files in general. > All other Borne-type shells I've tried have the historical > behavior. Bash behaves that way when run in Posix mode. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/