GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Case-statement and variables
Operating System - HP-UX
1847331
Members
2379
Online
110264
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
03-14-2001 03:17 AM
03-14-2001 03:17 AM
Why does this script respond whith "Wrong..." and "Right..." which I expected?
export POSSIBLE="6.6.01|6.6.02"
export CURRENT="6.6.01"
case $CURRENT in
$POSSIBLE)
echo "Right $CURRENT"
;;
(*)
echo "Wrong $CURRENT"
esac
export POSSIBLE="6.6.01|6.6.02"
export CURRENT="6.6.01"
case $CURRENT in
$POSSIBLE)
echo "Right $CURRENT"
;;
(*)
echo "Wrong $CURRENT"
esac
logics take you from A to B, imagination takes you anywhere
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2001 03:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2001 04:17 AM
03-14-2001 04:17 AM
Re: Case-statement and variables
Sorry. I typed too fast, I forgot the word "NOT".
I mean: Why does this script respond whith "Wrong..." and NOT whith "Right..." which I expected?
I mean: Why does this script respond whith "Wrong..." and NOT whith "Right..." which I expected?
logics take you from A to B, imagination takes you anywhere
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2001 04:52 AM
03-14-2001 04:52 AM
Re: Case-statement and variables
Hi,
I think that it fails because of the order in which the shell processes the case statement.
The first thing that it does is to split the lines into tokens that are serarated by the standard set of metacharacters:-
space tab newline ; ( ) < > | &
Later it performs parameter substitution on $POSSIBLE but this is too late for it to correctly handle the | characters.
You can force the shell to re-evaluate the command with the 'eval' statement and indeed if you try:-
eval "
"
then you get the result that you expected. Quoting of this form can cause problems though.
Hope this helps,
Regards,
John
I think that it fails because of the order in which the shell processes the case statement.
The first thing that it does is to split the lines into tokens that are serarated by the standard set of metacharacters:-
space tab newline ; ( ) < > | &
Later it performs parameter substitution on $POSSIBLE but this is too late for it to correctly handle the | characters.
You can force the shell to re-evaluate the command with the 'eval' statement and indeed if you try:-
eval "
"
then you get the result that you expected. Quoting of this form can cause problems though.
Hope this helps,
Regards,
John
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP