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

2022-12-13 Thread Lawrence Velázquez
On Tue, Dec 13, 2022, at 6:38 AM, Emanuele Torre wrote: > On Tue, Dec 13, 2022 at 03:07:16AM -0500, Lawrence Velázquez wrote: >> Of course not. I only meant to demonstrate that "export" always >> creates global variables, so a function that utilizes "declare -gx" >> actually behaves more like

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

2022-12-13 Thread Emanuele Torre
On Tue, Dec 13, 2022 at 03:07:16AM -0500, Lawrence Velázquez wrote: > Of course not. I only meant to demonstrate that "export" always > creates global variables, so a function that utilizes "declare -gx" > actually behaves more like "export" then your alias does. This is a little inaccurate.

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

2022-12-13 Thread Lawrence Velázquez
On Mon, Dec 12, 2022, at 4:43 AM, L A Walsh wrote: > On 2022/12/11 20:47, Lawrence Velázquez wrote: >> This happens because "declare"/"typeset" creates local variables >> within functions. Using -g works around this... >> >> $ Export() { declare -gx "$@"; } >> $ Export -r foo=1 >>

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

2022-12-12 Thread Chet Ramey
On 12/11/22 9:37 PM, L A Walsh wrote:  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]

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

2022-12-12 Thread L A Walsh
On 2022/12/11 20:47, Lawrence Velázquez wrote: This happens because "declare"/"typeset" creates local variables within functions. Using -g works around this... $ Export() { declare -gx "$@"; } $ Export -r foo=1 $ declare -p foo declare -rx foo="1" ...but now

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

2022-12-11 Thread Robert Elz
Date:Sun, 11 Dec 2022 18:37:02 -0800 From:L A Walsh 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

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

2022-12-11 Thread Lawrence Velázquez
On Sun, Dec 11, 2022, at 9:37 PM, L A Walsh wrote: > 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 "$@" > :; } > :;

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

2022-12-11 Thread L A Walsh
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