How can I display a list of shell variables in Bash, not including functions, which often clutter the output, because of the many related to completion?
I have examined declare, and it has an option for limiting the output to functions (declare -f), but not for limiting the output to "plain" shell variables?
declarewithout functions, i.e. just name/value pairs. Are functions also considered variables, or why doesdeclareinclude them? – Shuzheng Mar 26 '21 at 10:06bashshell stores functions as a special type of variable. Other shells do not do that. – Kusalananda Mar 26 '21 at 10:23f() { echo foo; }; f=bar– Shuzheng Mar 26 '21 at 10:30export -f f) and useprintenv, you would seeBASH_FUNC_f%%as the name. – Kusalananda Mar 26 '21 at 10:33bashshell, it can call the exported function. But you are getting side-tracked now. Your follow-up question was about the names of functions. I gave you an example that showed thatbashstores functions as variables. I used an exported function as an example so that I could use the external utilityprintenvto view its name. If I had used built-in utilities,bashwould have made it look like the function was just calledf. – Kusalananda Mar 26 '21 at 11:54bashabout what the currently defined functions are, it will list these for you using the names you have given them, even if these names seems to be the same as some variables' names. I.e., it maintains the illusion of separate name spaces for variables and functions, even though it actually stores functions as "special variables". If you have further questions about this particular topic, I suggest that you ask a separate question. – Kusalananda Mar 26 '21 at 12:29