On 5/4/20 8:39 AM, Chet Ramey wrote: > On 5/2/20 4:01 PM, Rob Landley wrote: > >> Why does the export flag on $_ toggle? > > It does three different things. It's initially exported if bash inherits it > from the environment at startup; after that it does its thing. > > "_ At shell startup, set to the absolute pathname used to invoke > the shell or shell script being executed as passed in the envi- > ronment or argument list. Subsequently, expands to the last ar- > gument to the previous simple command executed in the fore- > ground, after expansion. Also set to the full pathname used to > invoke each command executed and placed in the environment ex- > ported to that command. When checking mail, this parameter > holds the name of the mail file currently being checked." > > We picked that up from ksh.
My question was why "declare -p _" was showing -x sometimes and not other times, but I guess that's just an implementation detail showing through? (Unlike other magic variables, if you unset _ it doesn't stop being magic, it still gets reset every command. And if you "readonly _" bash gets REALLY chatty. :) Still trying to work out what the "bash spec" would be, vs implementation details... Rob _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net