- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Strange ksh behaviour
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
03-14-2005 07:01 AM
03-14-2005 07:01 AM
Strange ksh behaviour
(there are no *.cpp files in /, I get the same result on 10.20 and 11.11)
scchp2:/> [[ 1.cpp = '*'.cpp ]] ; echo $?
+ [[ 1.cpp = *.cpp ]]
+ echo 1
1
scchp2:/> a='1.cpp'; e=.cpp ;[[ $a = '*'$e ]]; echo $?
+ a=1.cpp
+ e=.cpp
+ [[ 1.cpp = *.cpp ]]
+ echo 0
0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2005 07:14 AM
03-14-2005 07:14 AM
Re: Strange ksh behaviour
If so, I think that it's your problem...
You're not comparing 1.cpp to "`.cpp" -
you're comparing 1.cpp to possibly "1".cpp.
Meaning - you might be finding true the match between "1.cpp" and "1" b/c you're adding ".cpp" to the find of "*" yourself, instead of asking the OS to match it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2005 07:23 AM
03-14-2005 07:23 AM
Re: Strange ksh behaviour
You are not expanding *.cpp to file listing here. With '*' * will be taken as literal character and will be compared with 1.cpp which is not true so you are getting 1 as output.
If you do same comparison without ''
[[ 1.cpp = *.cpp ]] ; echo $?
here * is treated as wild character so * will become 1 in this case and your result will true (0).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2005 07:28 AM
03-14-2005 07:28 AM
Re: Strange ksh behaviour
I should get the same result in both cases regardless of files existing in current directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2005 07:28 AM
03-14-2005 07:28 AM
Re: Strange ksh behaviour
I even thought it had to do with the protection of '*' - but moving it around and unprotecting it yields the same...
/# a='1.cpp'; e=.cpp ;[[ $a = '*'$e ]]; echo $?
0
/# a='1.cpp'; e='*'.cpp ;[[ $a = $e ]]; echo $?
0
/# a='1.cpp'; e=*.cpp ;[[ $a = $e ]]; echo $?
0
Interesting but at last I arrived at...
a='1.cpp'; e=*.cpp ;[[ $a = "$e" ]]; echo $?
1
So, I think it has to with the fact that the shell agrees that 1.cpp is a truth for an expansion of *.cpp; but in the last example the shell knows that the string "1.cpp" is NOT the same as the string literal "*.cpp".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2005 04:51 AM
03-17-2005 04:51 AM
Re: Strange ksh behaviour
Perhaps moderator could get HP-UX support's attention regarding the problem.