- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- What is the use of "set -u" in .profile?
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
Forums
Discussions
Discussions
Discussions
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
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
01-23-2004 03:05 AM
01-23-2004 03:05 AM
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2004 03:10 AM
01-23-2004 03:10 AM
Re: What is the use of "set -u" in .profile?
-u Treat unset parameters as an error when substituting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2004 03:17 AM
01-23-2004 03:17 AM
Re: What is the use of "set -u" in .profile?
From the ksh & sh-posix man page:
-u Treat unset parameters as an error when substituting
Which means I believe that during a command substitution - EX $(command) - that any parameters that may be necessary that are unset will result in an error & not defaulted.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2004 03:30 AM
01-23-2004 03:30 AM
SolutionIf you have any named $VAR and they are not defined (ie have no value) they will cause an error message when your .profile is executed as you login.
A $VAR cannot have a null value for your env when invoking your .profile
This is why sometimes you will see an error for "TERM not set" when you login
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2004 03:38 AM
01-23-2004 03:38 AM
Re: What is the use of "set -u" in .profile?
for MYNAME in $LIST_OF_FILES
do
rm -rf /usr/local/bin/$MYNAM
done
If set -u was executed prior to this code, it will stop before running the rm command because $MYNAME is not = $MYNAM and therefore, $MYNAM is undefined (actually misspelled but still undefined). If set +u is in force (the default) then the script would run:
rm -rf /usr/local/bin/
and the entire directory, all files and subdirectories, would be removed (that's a bad thing!). So to prevent these mistakes, use set -u.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2004 04:27 AM
01-23-2004 04:27 AM
Re: What is the use of "set -u" in .profile?
I wonder however what happens if you login with CDE. and .dtprofile sources .profile and an error occurs. Are you logged in or thrown out?
JP