X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/102ad2157b31642e029c8c176de1cc5b22c96599..2b0f31d36202b05a041644dc88951e19c530cddd:/package/nvram/src/main.c diff --git a/package/nvram/src/main.c b/package/nvram/src/main.c index a64430f7b..c42c28f1f 100644 --- a/package/nvram/src/main.c +++ b/package/nvram/src/main.c @@ -22,10 +22,19 @@ static void usage(void) { - fprintf(stderr, "usage: nvram [get name] [set name=value] [unset name] [show]\n"); + fprintf(stderr, "usage: nvram [get name] [set name=value] [unset name] [commit] [show]\n"); exit(0); } +/* hack for some PMON default nvram values which have '\r' appended */ +void +puts_trim_cr(char *str) +{ + int len= strlen(str); + if (len && (str[len-1] == '\r')) len--; + printf("%.*s\n", len, str); +} + /* NVRAM utility */ int main(int argc, char **argv) @@ -44,8 +53,9 @@ main(int argc, char **argv) for (; *argv; argv++) { if (!strncmp(*argv, "get", 3)) { if (*++argv) { - if ((value = nvram_get(*argv))) - puts(value); + if ((value = nvram_get(*argv))) { + puts_trim_cr(value); + } } } else if (!strncmp(*argv, "set", 3)) { @@ -66,7 +76,7 @@ main(int argc, char **argv) !strncmp(*argv, "getall", 6)) { nvram_getall(buf, sizeof(buf)); for (name = buf; *name; name += strlen(name) + 1) - puts(name); + puts_trim_cr(name); size = sizeof(struct nvram_header) + (int) name - (int) buf; fprintf(stderr, "size: %d bytes (%d left)\n", size, NVRAM_SPACE - size); }