HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Certain properties of shell variables
Operating System - HP-UX
1833756
Members
2414
Online
110063
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
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
10-08-2003 03:39 AM
10-08-2003 03:39 AM
Hi,
this is just an inferior aside to my "No Login..." thread (see below).
While I was contemplating about the savecrash stuff and looking at the various crash dump related init scripts and configuration files, I came accross this readonly variable declaration.
# grep typeset\ -r /sbin/init.d/savecrash
typeset -r DEFAULT_SAVECRASH_DIR=/var/adm/crash
Well I thought, nice feature of the POSIX shell I haven't made use of so far.
And at the shell I played, what happens if...
Let's see if maybe there is already tacitly being made use of such an esoteric feature?
# typeset -r
#
Relief, this doesn't seem to be standard fare.
So I need to define my own
# typeset -r outch=noli\ me\ tangere
# typeset -r
outch='noli me tangere'
swallowed it.
Isn't it funny how they foster ambiguity or Perl's TIMTOWTDI principle?
# readonly -p
readonly outch='noli me tangere'
# outch=really
sh: outch: This variable is read only.
ah, it's resisting.
But I want to get rid of this damned thingy
# typeset +r outch
sh: outch: This variable is read only.
# undef outch
sh: undef: not found.
# typeset -u -r outch
# readonly -p
readonly outch='NOLI ME TANGERE'
Oops, not what I intended.
It's getting presumptuous.
It even seems to survive accross subshells
# ( typeset -r; unset outch )
outch='NOLI ME TANGERE'
sh: outch: This variable is read only.
Does this mean such declared variables will only fall to demise whith the exit of the shell?
I haven't noticed this feature before and merely am amused.
this is just an inferior aside to my "No Login..." thread (see below).
While I was contemplating about the savecrash stuff and looking at the various crash dump related init scripts and configuration files, I came accross this readonly variable declaration.
# grep typeset\ -r /sbin/init.d/savecrash
typeset -r DEFAULT_SAVECRASH_DIR=/var/adm/crash
Well I thought, nice feature of the POSIX shell I haven't made use of so far.
And at the shell I played, what happens if...
Let's see if maybe there is already tacitly being made use of such an esoteric feature?
# typeset -r
#
Relief, this doesn't seem to be standard fare.
So I need to define my own
# typeset -r outch=noli\ me\ tangere
# typeset -r
outch='noli me tangere'
swallowed it.
Isn't it funny how they foster ambiguity or Perl's TIMTOWTDI principle?
# readonly -p
readonly outch='noli me tangere'
# outch=really
sh: outch: This variable is read only.
ah, it's resisting.
But I want to get rid of this damned thingy
# typeset +r outch
sh: outch: This variable is read only.
# undef outch
sh: undef: not found.
# typeset -u -r outch
# readonly -p
readonly outch='NOLI ME TANGERE'
Oops, not what I intended.
It's getting presumptuous.
It even seems to survive accross subshells
# ( typeset -r; unset outch )
outch='NOLI ME TANGERE'
sh: outch: This variable is read only.
Does this mean such declared variables will only fall to demise whith the exit of the shell?
I haven't noticed this feature before and merely am amused.
Madness, thy name is system administration
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 03:42 AM
10-08-2003 03:42 AM
Solution
Ralph,
"Does this mean such declared variables will only fall to demise whith the exit of the shell?"
Yes, that's exactly what it means. This is a useful feature if you want to set system-wide variables (in /etc/profile, for example), that you don't want the user to be able to change.
Pete
Pete
"Does this mean such declared variables will only fall to demise whith the exit of the shell?"
Yes, that's exactly what it means. This is a useful feature if you want to set system-wide variables (in /etc/profile, for example), that you don't want the user to be able to change.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 03:51 AM
10-08-2003 03:51 AM
Re: Certain properties of shell variables
a read only variable will give you an error message if you attempt to change the value, turn off its readonly attribute, or unset it.
it can still change value if it is a variable the the shell automatically changes such as PWD
doesn't make much since to have a read only variable that you can modify by just removing it and recreating it as desired.
it can still change value if it is a variable the the shell automatically changes such as PWD
doesn't make much since to have a read only variable that you can modify by just removing it and recreating it as desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 04:11 AM
10-08-2003 04:11 AM
Re: Certain properties of shell variables
Ok, I can see the need for this property.
But then I wouldn't call it variable but rather constant.
Maybe a more obvious, intuitive syntactic wrap on behalf of the shell designers wouldn't have astonished me.
In Perl they have the "use constant" pragma to this end.
But then I wouldn't call it variable but rather constant.
Maybe a more obvious, intuitive syntactic wrap on behalf of the shell designers wouldn't have astonished me.
In Perl they have the "use constant" pragma to this end.
Madness, thy name is system administration
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 2025 Hewlett Packard Enterprise Development LP