- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: difference between ksh and POSIX sh: assigning...
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
тАО10-21-2008 11:14 PM
тАО10-21-2008 11:14 PM
difference between ksh and POSIX sh: assigning SECONDS[1] quits
ksh quits the shell (or session) if an element of a *special* shell variable is tried to be initalized. "*special* shell variable" means shell variable updated internally by shell as SECONDS, RANDOM or _. Try
RANDOM[2]=45
Instead, POSIX sh allows these *special* shell variables to be arrays as ordinary variables and does not quit.
I've found a similar behaviour in Korn shell for Solaris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2008 11:59 PM
тАО10-21-2008 11:59 PM
Re: difference between ksh and POSIX sh: assigning SECONDS[1] quits
#0 0x0 in
#1 0x40531d0:0 in nam_putval+0x8b0
#2 0x403bf00:0 in env_namset+0x620
#3 0x403b840:0 in env_setlist+0xe0
#4 0x40379a0:0 in sh_exec+0x760
#5 0x4035170:0 in exfile+0x970
#6 0x4033ac0:0 in main+0xa50
Any reason you are trying to do that?
If you insist, you can simply unset the variable first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2008 03:21 AM
тАО10-22-2008 03:21 AM
Re: difference between ksh and POSIX sh: assigning SECONDS[1] quits
in ksh it is always recommended to declare arrays explicitly - whether you use a predefined variable or not.
root@hp1[192] set -A SECONDS
root@hp1[193] SECONDS[2]=aa
root@hp1[194] print ${SECONDS[2]}
aa
root@hp1[195] print ${#SECONDS[*]}
1
root@hp1[196] uname -a
HP-UX hp1 B.11.23 U ia64 2944899503 unlimited-user license
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-22-2008 10:24 PM
тАО10-22-2008 10:24 PM
Re: difference between ksh and POSIX sh: assigning SECONDS[1] quits
Try using the variable _ instead of SECONDS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2008 01:01 AM
тАО10-23-2008 01:01 AM
Re: difference between ksh and POSIX sh: assigning SECONDS[1] quits
at least for this SUN-Solaris this is NOT true (no HP-UX at hand today):
ef3nip00@malt uname -a
SunOS malt 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Fire-280R
ef3nip00@malt set -A _ aa bb cc
ef3nip00@malt echo ${_[0]}
aa
and even (in a new ksh) this works:
ef3nip00@malt echo $_
/usr/bin/ksh
ef3nip00@malt _[1]=hu
ef3nip00@malt echo ${_[*]}
/usr/bin/ksh hu
You could file a bug report - the docs tell us, that those variables loose their special meaning when manually modified, but there is no limitation on the type of the modifaction.
mfG Peter