LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 07-08-2004, 03:58 AM   #1
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
undocumented feature of setenv(3) in openbsd?


From the man page:

Quote:
int
setenv(const char *name, const char *value, int overwrite);

The setenv() function inserts or resets the environment variable name in
the current environment list. If the variable name does not exist in the
list, it is inserted with the given value. If the variable does exist,
the argument overwrite is tested; if overwrite is zero, the variable is
not reset, otherwise it is reset to the given value.
Looking at the source code for openbsd 3.5, one sees that not only can setenv be used in the form:
Code:
 setenv("dog", "spot", 1)
but also in the form:
Code:
 setenv("dog=spot", "spot", 1)
since any characters in name following an equal sign '=' (including the equal sign) are ignored by setenv.

As far as I can tell, this is not documented.

The man page does mention that name and value may be appended and prepended, respectively, with an equal-sign, so that the string "spot" in the above example may be replaced with "=spot" without any harm. (However, "spot" may not be replaced with "xxx=spot", since an equal-sign in value is ignored only in the case that the equal sign is the first character in the value string.

As such, this isn't a big deal. But, a look at the source code for env(1) reveals that this undocumented feature of setenv is being used: something of the form
Code:
env name=value command
is implemented by doing a setenv("name=value", "value", 1) rather than putenv("name=value") before calling an exec function to run command.

Seems to me this feature of setenv should be documented if it is to be used.
 
Old 07-08-2004, 04:56 AM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
aw heck. everybody knows that.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Upgrading undocumented server Gsee SUSE / openSUSE 0 07-18-2005 07:27 PM
setenv:too many argument petero Programming 1 06-02-2005 04:23 AM
setenv within a program doesn't last mvt Programming 8 04-26-2004 03:39 PM
Setenv IBP Linux - Software 3 12-20-2002 09:05 AM
setenv ???? toxic53 Linux - Networking 1 09-26-2001 11:30 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 04:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration