Date: Sun, 11 Dec 2022 18:37:02 -0800 From: L A Walsh <b...@tlinx.org> Message-ID: <639693ce.3060...@tlinx.org>
| 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? Not for me to say, but I doubt it. But it would be one more needless difference with very little benefit. And next you'd want readonly -x as yet another way to do the same thing. | I suppose one could create an alias (despite advice that | functions are "better" -- in this case a function doesn't work). They do, when used properly. | :; Export () { | :; typeset -x "$@" | :; } | :; Export -r foo_xr=1 | | :; typeset -p foo_xr | -bash: typeset: foo_xr: not found That's because typeset (declare) in a function makes local variables, even when you don't ask it to. I think that's a poor design (inherited from ksh, which had a non-shell-like design paradigm, more aiming to be a programming language). But bash has -g which instructs typeset/declare to make global instead of local vars. Add that and the function form works as you intended. And then if you want, the function can be extended to do more, which the alias cannot. kre