- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- return behaves differently in HP than in Sun
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
08-28-2002 05:48 PM
08-28-2002 05:48 PM
return behaves differently in HP than in Sun
Script s1:
========================
#!/usr/bin/ksh
echo about to call s2
. s2
echo have come out of s2 now
Script s2:
========================
#!/usr/bin/ksh
echo inside s2 now
return
When I run on SunOS I get:
===========================
>. s1
about to call s2
inside s2 now
have come out of s2 now
>
When I run on HP-UX I get:
===========================
>. s1
about to call s2
inside s2 now
>
!!! Pleaser note I am using . before I call
Thanks Nigel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 05:50 PM
08-28-2002 05:50 PM
Re: return behaves differently in HP than in Sun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 05:54 PM
08-28-2002 05:54 PM
Re: return behaves differently in HP than in Sun
If sun behaves differently, then it is wrong, not HP, because this is the NORMAL behavior expected.
If I was at work I'd test it with my sparky-5.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 06:13 PM
08-28-2002 06:13 PM
Re: return behaves differently in HP than in Sun
With the return removed from s2 on HP:
====================================
>. s1
about to call s2
inside s2 now
have come out of s2 now
- so that is what I want, however the
real s2 is a script, which, if I take the return out, it doesn't work because the return
gets out of:
select option in blah blah
do
case reply in
*) return;;
esac
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 06:16 PM
08-28-2002 06:16 PM
Re: return behaves differently in HP than in Sun
The HP behavior is actually correct. One NEVER issues an exit or a return from a sourced file for this reason (unless one really wants to exit the foreground process).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 06:18 PM
08-28-2002 06:18 PM
Re: return behaves differently in HP than in Sun
Thanks for the correct terminology.
The manpage for SunOS says about return:
=========================================
return causes a shell function or '.' script to return to the invoking script. If return is invoked while not in a function or a '.' script, then it is the same as an exit .
.... so at least Sun is doing what it syas it should do
...... I can't find an HP manpage for return
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 06:26 PM
08-28-2002 06:26 PM
Re: return behaves differently in HP than in Sun
************
The return command stops execution of a function and returns to the calling shell script with an exit status of n. If n is not specified, the returning status is that of the last command executed within the function. When return is invoked outside the boundaries of a function, it acts as an exit.
******************
Here is the shell users guide:
http://docs.hp.com/hpux/onlinedocs/B2355-90046/B2355-90046.html
The part about 'return' is in the Chapter 'POSIX and Korn Shell' in the 'Command Referecne section'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2002 06:38 PM
08-28-2002 06:38 PM
Re: return behaves differently in HP than in Sun
Thanks for the xplanantion. So maybe I should take it up at a Sun forum!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2002 03:26 AM
08-29-2002 03:26 AM
Re: return behaves differently in HP than in Sun
It should be reported to sun as a bug. BTW, what version of Solaris?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2002 03:47 PM
08-29-2002 03:47 PM
Re: return behaves differently in HP than in Sun
I have found this behaviour on
5.5.1
5.6
5.7
5.8
nb - the manpage says
"...return causes a shell function or '.' script to return to the invoking script ..."
But I tried without being source files & get the same !?
>cat s1
#!/usr/bin/ksh
echo about to call s2
s2
echo have come out of s2 now
>cat s2
#!/usr/bin/ksh
echo inside s2 now
return
>s1
about to call s2
inside s2 now
have come out of s2 now
>uname -rv
5.8 Generic_108528-14
>