On Sun, Jan 26, 2025, at 5:40 PM, Pete Edwards wrote:
> The set command executed should list the shell variables and values, 
> which
> it does, but it is followed by other text, which looks like script text
> that has no purpose in the output expectred.

The `set' built-in is documented to print both variables and functions
(when not in POSIX mode).

https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html


> Sample set command output
>  ACLOCAL_PATH=/clangarm64/share/aclocal:/usr/share/aclocal
> ALLUSERSPROFILE='C:\ProgramData'
> APPDATA='C:\Users\Administrator\AppData\Roaming'
>
> [...]
>
> WIN_ROOT=/c/Windows
> XDG_DATA_DIRS=/clangarm64/share/:/usr/local/share/:/usr/share/
> ZES_ENABLE_SYSMAN=1

Variables with names beginning with uppercase letters.


> _=pwd
> _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|@(dpkg|ucf)-*|rpm@
> (orig|new|save))))'
> _comp_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|@(dpkg|ucf)-*|rpm@
> (orig|new|save))))'
> _comp_dequote__regex_safe_word='^([^\'\''"$`;&|<>()!]|\\.|'\''[^'\'']*'\''|\$?"([^\"$`!]|\$([_a-zA-Z][_a-zA-Z0-9]*|[-*@#?$!0-9_])|\$\{[!#]?([_a-zA-Z][_a-zA-Z0-9]*(\[([0-9]+|[*@])\])?|[-*@#?$!0-9_])\}|\\.)*"|\$'\''([^\'\'']|\\.)*'\''|\$([_a-zA-Z][_a-zA-Z0-9]*|[-*@#?$!0-9_])|\$\{[!#]?([_a-zA-Z][_a-zA-Z0-9]*(\[([0-9]+|[*@])\])?|[-*@#?$!0-9_])\})*$'

Variables with names beginning with underscores.


> _comp_xspecs=([tex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)"
> [freeamp]="!*.@(mp3|ogg|pls|m3u)" [gqmpeg]="!*.@(mp3|ogg|pls|m3u)"
> [texi2html]="!*.texi*" [hbpp]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])"
>
> [...]
>
> [slitex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)"
> [aaxine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))"
> [advi]="!*.dvi" [lzmore]="!*.@(tlz|lzma)" )

One very long associative array.


> postinst=/etc/post-install/07-pacman-key.post

Variables (in this case, *a* variable) with names beginning with
lowercase letters.


> __expand_tilde_by_ref ()
> {
>     [[ -n ${1+set} ]] || return 0;
>     [[ $1 == REPLY ]] || local REPLY;
>     _comp_expand_tilde "${!1-}";
>     [[ $1 == REPLY ]] || printf -v "$1" "$REPLY"
> }
>
> [...]
>
> quote_readline ()
> {
>     local REPLY;
>     _comp_quote_compgen "$1";
>     printf %s "$REPLY"
> }

The aforementioned functions.


> This stuff looks to be an artifact of a bug

Again, this behavior is documented.  It is not a bug.


> and results in data at the end
> of the output that is not part of the expected key value list and
> therefore makes it harder to parse the shell variables and values.

You might try POSIX mode, or `declare -p` without arguments.  Others
will offer more suggestions, I'm sure.


-- 
vq

Reply via email to