- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: What does "$-" mean?
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
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
тАО04-07-2008 08:37 AM
тАО04-07-2008 08:37 AM
if test "`echo $- |grep i`"
I don't know what is that for. And I run it out side the script, the answer is:
# echo $-
isum
while running inside the script, it is
# echo $-
vxuh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2008 08:44 AM
тАО04-07-2008 08:44 AM
Re: What does "$-" mean?
The '-' shell variable ('$-') is the list of single letter options currently set. You see this when you do:
# echo $-
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2008 08:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2008 10:31 AM
тАО04-07-2008 10:31 AM
Re: What does "$-" mean?
... and if you modify that script, use
case "$-" in
*i*) ...
;;
easc
instead - no need for an extra process for handling this flag.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2008 03:28 PM
тАО04-07-2008 03:28 PM
Re: What does "$-" mean?
Since the sample code is detecting the "i" (interactive) option for the current shell, the modern way is to replace the whole line:
if test "`echo $- |grep i`"
with
if tty -s
Much more readable and avoids the use of the deprecated "test" construct (use [[ ]]).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2008 11:01 PM
тАО04-07-2008 11:01 PM
Re: What does "$-" mean?
a replacement, using only builtins for
if tty -s
...
would be
if [ -t 1 ]
...
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2008 06:57 AM
тАО04-08-2008 06:57 AM
Re: What does "$-" mean?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2008 07:04 AM
тАО04-08-2008 07:04 AM
Re: What does "$-" mean?
> Do they work in Korn shell?
Well, the easy way to find the answer is to try it!
Yes, the tests for interactivity work in the Korn shell. On HP-UX, however, your standard shell is the Posix one ('/sbin/sh' for root; and '/usr/bin/sh' for non-root users).
Regards!
...JRF...