From a618b193284dd1c88d2fcd4c62f7a5a2dab1c72f Mon Sep 17 00:00:00 2001 From: Fedor Date: Wed, 27 May 2009 01:53:20 -0400 Subject: [PATCH] Fixes for "nvram export" command output --- release/src/router/nvram/nvram.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/release/src/router/nvram/nvram.c b/release/src/router/nvram/nvram.c index 3593c2052f..38731a349f 100644 --- a/release/src/router/nvram/nvram.c +++ b/release/src/router/nvram/nvram.c @@ -284,7 +284,7 @@ static int export_main(int argc, char **argv) int mode; // C, set, quote - static const char *start[4] = { "\"", "nvram set \"", "{ \"", "" }; + static const char *start[4] = { "\"", "nvram set ", "{ \"", "" }; static const char *stop[4] = { "\"", "\"", "\" },", "" }; @@ -315,21 +315,31 @@ static int export_main(int argc, char **argv) do { switch (*p) { case 9: - printf("\\t"); + if (mode == X_SET) putchar(*p); + else printf("\\t"); break; case 13: - printf("\\r"); + if (mode == X_SET) putchar(*p); + else printf("\\r"); break; case 10: - printf("\\n"); + if (mode == X_SET) putchar(*p); + else printf("\\n"); break; case '"': case '\\': printf("\\%c", *p); break; + case '$': + case '`': + if (mode != X_SET) putchar(*p); + else printf("\\$"); + break; case '=': - if ((eq == 0) && (mode > X_SET)) { - printf((mode == X_C) ? "\", \"" : "\t"); + if ((eq == 0) && (mode > X_QUOTE)) { + printf((mode == X_C) ? "\", \"" : + ((mode == X_SET) ? "=\"" : "\t")); + eq = 1; break; } eq = 1; -- 2.11.4.GIT