Re: [U-Boot] [PATCH 1/3] hush: Add default value substitution support
Dear Joe Hershberger, In message 1345235191-13757-1-git-send-email-joe.hershber...@ni.com you 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. Signed-off-by: Joe Hershberger joe.hershber...@ni.com --- common/hush.c | 43 --- 1 file changed, 40 insertions(+), 3 deletions(-) Applied, thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de It is the quality rather than the quantity that matters. - Lucius Annaeus Seneca (4 B.C. - A.D. 65) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] hush: Add default value substitution support
Dear Joe, In message 201208171931.35608.vap...@gentoo.org Mike Frysinger wrote: ${VAR:-default} ... ${VAR:=default} ... ${VAR:+default} ... how about ${VAR-default} and ${VAR=default} and ${VAR+default} ? Maybe we (= you?) can add these, too? + if (assign) { + char *var = malloc(strlen(src)+strlen(default_val)+2); please put spaces around the + Ah, I missed that. + if (var) { + sprintf(var, %s=%s, src, default_val); + set_local_var(var, 0); + } isn't there a helper func for this ? Eventually we can lean this up in another patch, please? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de The ideal situation is to have massive computing power right at home. Something that dims the streetlights and shrinks the picture on the neighbours' TVs when you boot it up. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] hush: Add default value substitution support
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 signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot