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

Re: path PATH




On 2023-01-22 04:29, Roman Perepelitsa wrote:

Perhaps you can use something like this to describe parameters:

     describe-param() {
       emulate -L zsh
       [[ ARGC -eq 1 && -n $1 ]] || return
       set -- "$@" ${(Pt)1}
       [[ -$2- == *-hide-* ]] && return 1
       print -rn -- "$2 ${(q-)1}"
       if [[ -$2- == *-hideval-* ]]; then
         print
       else
         set -- "$@" ${(M)2:#(array|association)(|-*)}
         print -r -- "=${3:+( }${(j: :)${(@qqq)${(@kv)${(@P)1}}}}${3:+ )}"
       fi
     }

Fantastic.  I've never seen parameter descriptions of that sort. So verbal, so helpful , so complete.  Whoever coded that was a friend of humanity that day:

5 /aWorking/Zsh/Source/Wk 0 $ describe-param PATH
scalar-tied-export-special PATH=".:/aWorking/Zsh/System:/aWorking/Bin:/usr/local/bin:/usr/sbin:/usr/bin"

5 /aWorking/Zsh/Source/Wk 0 $ describe-param path
array-tied-special path=( "." "/aWorking/Zsh/System" "/aWorking/Bin" "/usr/local/bin" "/usr/sbin" "/usr/bin" )

... ALL the information, all the time.  I'll bet it even works on Tuesdays.  Dunno, it's mostly a psychological thing but whereas most of the time brief, compact information is all you need, it is nice to know that when you hafta, you can get ALL the information.  I learn that PATH is exported and path is not!  Who knew?  typeset -p obfuscates more than helps.  But, as Bart was saying, we can't export arrays (why not? it seems arbitrary), so that's what PATH is for.  Complete information explains itself. If I'd had that function from the getgo, this entire thread would have been unnecessary, the issue would have explained itself. It's going to be a good day.






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