- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- what is "set" and "set -u" command?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2002 11:22 PM
тАО02-13-2002 11:22 PM
What is "set" and "set -u" command? I found them in .prfile on home directory.
Thank in advance for you answer.
Worapoj
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2002 11:27 PM - last edited on тАО09-30-2020 06:16 AM by Vajith V
тАО02-13-2002 11:27 PM - last edited on тАО09-30-2020 06:16 AM by Vajith V
SolutionCheck out 'man ksh'
set -u will treat unset parameters as an error while substititing, rather than substituting them with a blank.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2002 11:31 PM
тАО02-13-2002 11:31 PM
Re: what is "set" and "set -u" command?
See man page sh-posix
The set command with neither arguments nor options displays the
names and values of all shell parameters on standard output. See
also env(1).
set -u treat unset parameters as an error when substituting.
| set [{-|+}abCefhkmnopstuvx] [{-|+}o option]... [{-|+}A
name] [arg]...
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2002 11:32 PM
тАО02-13-2002 11:32 PM
Re: what is "set" and "set -u" command?
pls advise,
worapoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-13-2002 11:56 PM
тАО02-13-2002 11:56 PM
Re: what is "set" and "set -u" command?
running "set" without parameters does exactly the same thing as running "env". However, like Deepak and Steve pointed out, "set" can also be use to exert control over how environment variables are treated.
For example, if you issue:
#echo $UNSET_VARIABLE
a blank line will be echoed.
Now, do the following:
#set -u
#echo $UNSET_VARIABLE
"echo" will generate an error message stating that the variable UNSET_VARIABLE is not set.
HTH
Vincent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 12:05 AM
тАО02-14-2002 12:05 AM
Re: what is "set" and "set -u" command?
You meant #set do the same same #export like? For example,
#export NAME=Worapoj
#print $NAME
Worapoj
like
#set NAME_A=Worapoj_A
but
#print $NAME_A
Parameter not set.
Please advise,
Worapoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 12:18 AM
тАО02-14-2002 12:18 AM
Re: what is "set" and "set -u" command?
"set" can be used to:
a) print environment variables (like "env")
b) tell the shell how to treat variable references. If you try to echo a variable which does not yet exist, "echo" will normally print a blank line. If you do a "set -u" first and then echo the same non-existing variable, the shell will complain about empty variable references (i.e. a reference to a variable which has no value assigned to it).
Hope this helps.
Vincent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 12:26 AM
тАО02-14-2002 12:26 AM
Re: what is "set" and "set -u" command?
Another one what difference with #set and #env , as you told is display the same thing.
Pease advise,
Worapoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 12:27 AM
тАО02-14-2002 12:27 AM
Re: what is "set" and "set -u" command?
set is not equivalent to export!
Steve has mentioned the syntax of set. It is typically used with the following options: {-|+}abCefhkmnopstuvx , each having a specific meaning, which you can get from the man page of ksh or sh-posix.
I think what Vincent aka devnull aka HTH (??) meant was that 'set' without any parameter will yield the same output as 'env', but this is valid ONLY IF NO PARAMETER IS PASSED to set.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2002 12:52 AM
тАО02-14-2002 12:52 AM
Re: what is "set" and "set -u" command?
HTH = Hope This Helps