stevesu@copper.UUCP (06/07/87)
Some time ago (I think it was with the new version of ctime, or something) a new library routine, setenv, was posted. This routine adds or modifies entries in the process's environment. It checks to see if the new entry is longer than the old one, so it can malloc extra space if necessary. Unfortunately, the test is reversed. The result is that when an environment variable's value is replaced with a longer one, the new value overwrites succeeding variables, typically changing their names to something un-alphabetic and causing the dreaded "not an identifier" errors from subshells. (Hasn't one of the newer shells figured out how to make that a non-fatal error? Both the Bourne and the Korn shells I have here abort.) The fix is simple: just change one <= to >=. Steve Summit stevesu@copper.tek.com *** setenv.orig.c Sun Mar 29 16:12:08 1987 --- setenv.c Sat Jun 6 23:36:43 1987 *************** *** 34,40 if ((C = _findenv(name,&offset))) { /* find if already exists */ if (!rewrite) return(0); ! if (strlen(C) <= l_value) { /* smaller; copy over */ while (*C++ = *value++); return(0); } --- 34,40 ----- if ((C = _findenv(name,&offset))) { /* find if already exists */ if (!rewrite) return(0); ! if (strlen(C) >= l_value) { /* old larger; copy over */ while (*C++ = *value++); return(0); }