From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20882 invoked from network); 21 Oct 2022 14:25:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Oct 2022 14:25:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1666362343; b=Un89KO497U7T1tDEreqhyIgk1/EFmY4usY2auu5tgPdXBgPXpzKU0I0w7Wqz7Sye0PDaDUr7fV AFsLGwdOie+rHY15U5VwNJqWrfzfwWHd1Lnv9TRUDpVenGXI52xVjDup+aZbF5s+gwH1bcjGBK wFMEw8PrXfefWUC52iCn8DMK61kwMlg5cGznE89IicRSXHH3X+QhwAQayXUOkJX379nQyJaGQi 6GRH1/kWFd/kwO7bbPD93+l+IOlkUW3oYMTriL/Kh06KB8OWO74TgKBLu7/KLRCop5ypbwyGUw vMvGcJ/1fzdEWDgGKeayUhBq0T07yinSO89XwZaSEP7xFg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1666362343; bh=4tyIy7YIT6puMqJCmZgCc0DNnt1X63ayYLSRQHK92UU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=f6nLvTZN6c6KWEA7bIHV0GqdCRcZjQAZU+JuvDkWiwKN8/b3iu+p7D4SE9jATNnsdCwXA/1s9m qY2G2IYBQ5Qf4RzA1y92E0a2dW0uY4Kc43hHq6xmWKYVCiaChVfsyJXRrZN7sICBZ27Rh/9mQc t/2oLJjkga0iGhBUikiP15GPdgGu/pO1hlLfG9+QmeHoJjIX0+JTw7HKEHmgRZ9/XgebfQLNyA MSRrE9C7pRUAhlKJXiPL5KMflzm1WBCSh5HCbPbT4UZrivg6BnMzjy0diR7M1+SllWD39foeug 80FkU87vHFYggENYGbRcrwzuPjf1QAAdvjOX7wxT75/goQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=QPv0UcstK9bsUQGHQ2Chu0X3HJ1Cl/mVkgKCARtrp6w=; b=N1SJ4I5+5mw+LO9FUCXb58Gqlf nY9efacIii+2z/jnKzajGN7rNan8o6cIElIjiMA2oyRsxReCWS/7M45i+iq6qQtM9m6BSB6vYE1h+ uYIbg5Q733UO+yLEZZ7Ee61/uY/iFsP2xD8ynNDJ61DZAv6vE0qdGExpZacTb128cZm5/oyDzoi00 XdoumO70+AbfptsO/6twQ+VWmamoAjzveHoLVXjo6PUYud/Jva5HOgO6tDtY5XplQLb/Zz41kplkt cmRLucs0Q8VU0vur9VDie87VOKZhS1OXN6AAs9VmyRafQeUFDGZDjm9BjTOwwgyKiXYBaWlr9MbjT 8By0Yxhg==; Received: by zero.zsh.org with local id 1olsxw-000PgB-Vc; Fri, 21 Oct 2022 14:25:41 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:55171) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1olsxG-000OyE-6K; Fri, 21 Oct 2022 14:24:58 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta04.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RK300071UHWYXE0@mta04.eastlink.ca> for zsh-users@zsh.org; Fri, 21 Oct 2022 11:24:36 -0300 (ADT) Received: from [192.168.0.2] ([24.207.18.108]) by Eastlink with ESMTPSA id lswtoNTQjG1iNlswtoBqXZ; Fri, 21 Oct 2022 11:24:35 -0300 X-Authority-Analysis: v=2.4 cv=Ndkja0P4 c=1 sm=1 tr=0 ts=6352aba3 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=HUSBInAQnxQ__DwKXhAA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeelkedgjeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrvdgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: Date: Fri, 21 Oct 2022 07:24:35 -0700 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: var=$( typeset "$1" ) ... not within a function. To: zsh-users@zsh.org References: <5f18c162-e111-21ba-3ebe-ece09a477ecd@eastlink.ca> <552657de-31ce-255a-bc8d-7c9cd4b8eabd@eastlink.ca> <530b18d0-5e72-6afd-7448-cdff9c119bda@eastlink.ca> Content-language: en-US From: Ray Andrews In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28246 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 2022-10-20 19:25, Bart Schaefer wrote: > ... but the same command from within a script or function gives: >> typeset -g -T CDPATH cdpath=( ) > The -g is because typeset -p is supposed to be outputting a command > that can be sent back through "eval". If you were to execute that > typeset without the -g when inside a function, you would create a new > local CDPATH variable. The -g makes sure you are still referencing > the global. It's a bit awkward.  When I'm clearly looking for information, not trying to 'do' anything I'd expect that the information is the information.  But I sorta see what  you mean, if the output is taken as the input to an 'eval' then ... well I dunno, but it ends up giving different answers to the same question. > >> ... and if I scan the entire output of "$ typeset -p" and look for >> 'CDPATH' I get: >> >> typeset -T CDPATH cdpath=( ) >> typeset -aT CDPATH cdpath=( ) > The first one is the (incorrect) assignment for $CDPATH. > The second one is the (correct) assignment for $cdpath. > These are "tied" variables (the -T) meaning that if you change either > one of them, the other also changes. So then there is logic to having them on the same line, but no logic to having two separate lines, that's progress. My specific little goal here is of little concern to the list but just in case anyone is interested in why I'm flogging this, one of my wrappers is designed to give you every possible usage of an identifier, be it a variable of any flavor, an alias, executable, builtin ... whatever else it might possibly be of interest to the shell. So it uses all the half dozen or so tools that might have something to say.  But it is designed to be case sensitive or not and to use wildcards.  But when it comes to the parameters (variables?) 'printenv' is always case sensitive and doesn't take wildcards but 'typeset' is never case sensitive and does take wildcards.  'set' doesn't have internal filters at all.  So, to add case sensitivity to the output of typeset I just run it thru a 'sed' for filtering and colorizing (which you can't see below of course).  So, if I want to know if, case insensitively, what "*path*" might mean to the shell: (the command is called 'i' for 'information): $ . i; i "*path*" EXACT search of the environment for "*path*" ... No exact match found. Case INsensitive WILD search for all variables matching: "*path*" typeset -g -T CDPATH cdpath = (  ) typeset -g -T FPATH fpath = ( /usr/local/share/zsh/site-functions ... typeset -g -T MAILPATH mailpath = (  ) typeset -g -T MANPATH manpath = (  ) typeset -g -T MODULE_PATH module_path = ( /usr/lib/x86_64-linux-g ... export -T PATH path = ( . /aWorking/Zsh/System /aWorking/Bin /usr ... export XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0 export XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session ... typeset -g -aT CDPATH cdpath = (  ) typeset -g -aT FPATH fpath = ( /usr/local/share/zsh/site-function ... typeset -g -aT MAILPATH mailpath = (  ) typeset -g -aT MANPATH manpath = (  ) typeset -g -aT MODULE_PATH module_path = ( /usr/lib/x86_64-linux- ... typeset -g -aT PATH path = ( . /aWorking/Zsh/System /aWorking/Bin ... typeset -aU ppath = ( /aWorking/Zsh/Source/Wk /aWorking/Zsh/Syste ... Searching the path for unexecutable scripts or text files: None found. Searching for alias, function, builtin, or executable script or binary on the path: Found 20 match(es): (1)TYPE: _absolute_command_paths is an autoload shell function: (2)TYPE: _canonical_paths is an autoload shell function: (3)TYPE: _cygpath is an autoload shell function: (4)TYPE: _path_commands is an autoload shell function: (5)TYPE: _path_files is an autoload shell function: (6)TYPE: _systemd-path is an autoload shell function: (7)TYPE: _tracepath is an autoload shell function: (8)TYPE: path is a shell function from miscfunctions: (9)TYPE: dpkg-realpath is /usr/bin/dpkg-realpath: CONTENT: EXECUTABLE SCRIPT (10)TYPE: dpkg-realpath is /bin/dpkg-realpath -> /usr/bin/dpkg-realpath: CONTENT: EXECUTABLE SCRIPT (11)TYPE: grub-mkrelpath is /usr/bin/grub-mkrelpath: CONTENT: EXECUTABLE UNKNOWN (12)TYPE: grub-mkrelpath is /bin/grub-mkrelpath -> /usr/bin/grub-mkrelpath: CONTENT: EXECUTABLE UNKNOWN (13)TYPE: manpath is /usr/bin/manpath: CONTENT: EXECUTABLE UNKNOWN (14)TYPE: manpath is /bin/manpath -> /usr/bin/manpath: CONTENT: EXECUTABLE UNKNOWN (15)TYPE: pathchk is /usr/bin/pathchk: CONTENT: EXECUTABLE UNKNOWN (16)TYPE: pathchk is /bin/pathchk -> /usr/bin/pathchk: CONTENT: EXECUTABLE UNKNOWN (17)TYPE: realpath is /usr/bin/realpath: CONTENT: EXECUTABLE UNKNOWN (18)TYPE: realpath is /bin/realpath -> /usr/bin/realpath: CONTENT: EXECUTABLE UNKNOWN (19)TYPE: systemd-path is /usr/bin/systemd-path: CONTENT: EXECUTABLE UNKNOWN (20)TYPE: systemd-path is /bin/systemd-path -> /usr/bin/systemd-path: CONTENT: EXECUTABLE UNKNOWN ========================================= You'll all find it grotesque overkill but to me it's one stop shopping for whatever "*path*" might happen to be.  But notice the double finds above when 'typeset' is filtered thru sed: typeset -g -T CDPATH cdpath = (  ) typeset -g -aT CDPATH cdpath = (  ) ... it's just a bit annoying and it looks like Bart agrees it's a bug so that will be cured and of course '-aT' is correct.  (If case sensitivity was built in to typeset I'd not have to bother with the sed filter at all.  Seems to me that since we already have the use of wildcards there, case sensitivity would be a natural enhancement.  Dunno, maybe '-M' ... capital M means wildcards plus case sensitive.) > ... and while I'm whining I notice that 'set' never does anything like: >> "CDPATH cdpath", it puts them on separate lines. Dunno, couldn't they >> have separate values? > No, they can't. One is a colon-separated string and the other is an > array, but they always track one another. Understood.  So they really should be on the same line.  So then the questionable output would be from 'set' which shows them separately as tho they were strangers.  Mind, set doesn't output any type information at all so maybe that's OK.