bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

curiosity: 'typeset -xr' vs. 'export -r'


From: L A Walsh
Subject: curiosity: 'typeset -xr' vs. 'export -r'
Date: Sun, 11 Dec 2022 18:37:02 -0800
User-agent: Thunderbird

 This is mostly a 'nit', but I noticed I had
   "typeset -xr"
 in one of my scripts to mean export+read-only and
 was wondering why
   "export -r"
 was disallowed (err message):

bash: export: -r: invalid option
export: usage: export [-fn] [name[=value] ...] or export -p

This seems to be an unnecessary "make-wrong", no?  I.e.
would it cause some syntactic or semantic problem in bash,
if it were allowed?

I suppose one could create an alias (despite advice that
functions are "better" -- in this case a function doesn't work).
I'm using ':;' for PS1, so cut/paste works:

 PS1=':; '

:; Export () {
:;   typeset -x "$@"
:; }
:; Export -r foo_xr=1

:; typeset -p foo_xr
-bash: typeset: foo_xr: not found

#   vs. alias implementation:

:; alias Export='typeset -x '
:; Export -r al_foo_xr=1

:; typeset -p al_foo_xr
declare -rx al_foo_xr="1"

Please forgive the noise if this has already been addressed as my bash
is not fully up to date.  Thanks!
-linda




reply via email to

[Prev in Thread] Current Thread [Next in Thread]