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

Re: var=$( typeset "$1" ) ... not within a function.




On 2022-10-20 10:29, Mikael Magnusson wrote:
On 10/20/22, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
function ii ()
{
      var=$( printenv "$1" )
      [ "$var" ] && var=$( typeset "$1" )
      print "var is: $var    "
}
What kind of logic is behind this code? You first check if the given
name is in the environment, then you assign over the same parameter
again with the same value using another way to get the value.

There is method in my madness.  printenv there returns "root", typeset return "USER=root" and more importantly printenv does not accept wildcards and  ... nevermind -- the point is that whatever my motives, it seems strange that the code doesn't work when inside a function.







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