From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Fri, 17 Aug 2012 19:31:34 -0400 Subject: [U-Boot] [PATCH 1/3] hush: Add default value substitution support In-Reply-To: <1345235191-13757-1-git-send-email-joe.hershberger@ni.com> References: <1345235191-13757-1-git-send-email-joe.hershberger@ni.com> Message-ID: <201208171931.35608.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday 17 August 2012 16:26:29 Joe Hershberger wrote: > Use standard sh syntax: > ${VAR:-default} > Use default value: if VAR is set and non-null, expands to $VAR. > Otherwise, expands to default. > ${VAR:=default} > Set default value: if VAR is set and non-null, expands to $VAR. > Otherwise, sets hush VAR to default and expands to default. > ${VAR:+default} > If VAR is set and non-null, expands to the empty string. > Otherwise, expands to default. how about ${VAR-default} and ${VAR=default} and ${VAR+default} ? > --- a/common/hush.c > +++ b/common/hush.c > > + if (sep) { > + *sep = '\0'; > + if (*(sep + 1) == '-') switch (sep[1]) { case '-': ... > + default_val = sep+2; sep + 2 > + if (!p || strlen(p) == 0) { if (!p || !p[0]) > + if (assign) { > + char *var = malloc(strlen(src)+strlen(default_val)+2); please put spaces around the "+" > + if (var) { > + sprintf(var, "%s=%s", src, default_val); > + set_local_var(var, 0); > + } isn't there a helper func for this ? -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: