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

Re: Read-only variables in emulation mode



On Jun 16,  8:24am, Mikael Magnusson wrote:
}
} > On Jun 16,  2:10am, Mikael Magnusson wrote:
} > }
} > } % echo hi; _=foo; echo $_
} > } hi
} > } hi
} >
} > That's actually a bug -- the assignment _=foo should erase $_ , I think.
} >
} > } % for _ in a b c; do echo $_ hi; done
} > } hi
} > } hi hi
} > } hi hi
} >
} > If you go back to the original message in the thread, the whole point
} > was to use $_ as a dummy variable that didn't need to be declared and
} > whose value was instantly discarded.  For that purpose, the warning is
} > extraneous.
} 
} It's currently hooked up to nullstrsetfn, and was when it was readonly
} too, so I guess this never worked as intended.

I'm not sure what "never worked as intended" is aimed at.

"That's actually a bug" -- $_ should be erased because there is no command
for a last argument to be taken from, not because it's been assigned foo.

"use $_ as a dummy variable" -- that didn't work as intended before, but
it does now.

So what never worked and what was intended?

As with $0 in the other thread, "local -h _" works.



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