sh: SHELLOPTS: readonly variable - solved

"Richard Finegold" <[email protected]> Mon, 10 May 2004 21:03:21 -0700
Newsgroups gmane.network.bb4.devel
Message-ID <[email protected]>
deadcat's "perlshell.pl" (and any derivative thereof) has code that
parses bbdef.sh:
##
unless (exists $ENV{BBTMP}) {
        foreach (`chdir \$BBHOME;. etc/bbdef.sh;set`) {
                chomp;
                ($var,$val)=/^\s*(.*?)\s*=\s*(.*)/;          # get var
and value
                $ENV{$var}=$val;                             # and set
        }
}
##
but this can trip on the SHELLOPTS variable, leading to this error on
some platforms:

	sh: SHELLOPTS: readonly variable

on a simple line of perl code such as:

	print `/bin/echo N\*8`;

presumably due to attempts at variable matching/globbing. To prevent
this, skip over the SHELLOPTS variable - the above code becomes:
##
unless (exists $ENV{BBTMP}) {
        foreach (`chdir \$BBHOME;. etc/bbdef.sh;set`) {
                chomp;
                ($var,$val)=/^\s*(.*?)\s*=\s*(.*)/;          # get var
and value
                next if ($var eq "SHELLOPTS" );
                $ENV{$var}=$val;                             # and set
        }
}
##

The same should apply if anyone gets:
	sh: UID: readonly variable
but somehow skipping SHELLOPTS was adequate for my tests.

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=
To unsubscribe from this list send e-mail to mailto:[email protected]
with unsubscribe bbd in the BODY of the message.