Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: this should be easy variable expansion including globs.



Nikolay Aleksandrovich Pavlov (ZyX) wrote on Wed, Jan 18, 2017 at 23:12:34 +0300:
> Alternative solutions are […] using zsh/parameter module, there will
> be $parameters associative array which may be searched by indexing
> (find `Subscript Flags` section in man pages, though I failed to
> construct a useful subscript) and definitely can be processed in
> a cycle.

% typeset -p ${(k)parameters[(I)SMART*]} >! somefile

1. $parameters is an associative array mapping parameter names to
I don't know what.

2. (I)SMART* causes the parameter expansion to match all key-value pairs
where the key matches "SMART*".

3. (k) means: for each matched pair, the expansion shall contain the
key.

Bug: when there are no variables named SMART*, this will run «typeset
-p» which will output all variables.  You could guard against that with
.
    local -a names=( ${(k)…} )
    (( $#names )) || return 1

-------

Now, having said all that: the Internet says that the smartd(8) man page
documents the available parameters.  That isn't the case on my box, but
my smartd(8) might be out of date.

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author