[U-Boot] [PATCH 1/3] hush: Add default value substitution support
Mike Frysinger
vapier at gentoo.org
Sat Aug 18 01:31:34 CEST 2012
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: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/bebecff0/attachment.pgp>
More information about the U-Boot
mailing list