On Wednesday, August 25, 2010 00:59:58 Jan Schampera wrote: > Mike Frysinger wrote: > > the difference here being the value in variable "a" after function "f" > > finishes executing. i was expecting the behavior of `bash`, not of `sh`. > > i cant seem to find anything covering this in the man page except for > > perhaps interpreting the meaning of some sections to mean this behavior > > is allowed. but i certainly didnt locate anything that would imply > > behavior of this would differ across bash and sh ... > > I'd expect "VAR=VAL <simple command>" to behave like in your "bash" > example, in any case (i.e. also for functions!). Just intuitively, I > mean. I don't know any standard documents about it, maybe it is > "implementation defined", as so often. > > Dash behaves the same way as your "sh" example, Korn too. Z behaves like > the "bash" example here. So I fear it actually isn't standardized and > you can't operate with functions the same way you operate with separate > processes.
unfortunately, ive relied on this bash behavior in the past in bash-specific scripts because it's an easy way of tweaking a variable's value for a specific command without having to save/restore context. which is why i was surprised when it didnt work in a #!/bin/sh script (which had sh->bash). not that standards bodies care about the pains they inflict upon me ;). -mike
signature.asc
Description: This is a digitally signed message part.