[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: discrepancy with variable assignments and simple commands between sh

From: Mike Frysinger
Subject: Re: discrepancy with variable assignments and simple commands between sh and bash
Date: Wed, 25 Aug 2010 01:13:08 -0400
User-agent: KMail/1.13.1 (Linux/; KDE/4.4.5; x86_64; ; )

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 ;).

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]