From: Dmitry Volyntsev Date: Fri, 20 Jul 2018 17:11:02 +0000 (+0300) Subject: Improved help desrcription of njs shell. X-Git-Tag: 0.2.3~11 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=e6fed582c46154a99b78bf5176c740b6cf8f11f3;p=njs.git Improved help desrcription of njs shell. --- diff --git a/njs/njs_core.h b/njs/njs_core.h index 11c9cc9d..ea6d3726 100644 --- a/njs/njs_core.h +++ b/njs/njs_core.h @@ -9,6 +9,7 @@ #include +#include #include #include #include diff --git a/njs/njs_shell.c b/njs/njs_shell.c index ffcd8a25..8053ac21 100644 --- a/njs/njs_shell.c +++ b/njs/njs_shell.c @@ -150,6 +150,14 @@ njs_get_options(njs_opts_t *opts, int argc, char** argv) char *p; nxt_int_t i, ret; + static const char help[] = + "Interactive njs shell.\n" + "\n" + "Options:\n" + " -v print njs version and exit.\n" + " -d print disassembled code.\n" + " | - run code from a file or stdin.\n"; + ret = NXT_DONE; for (i = 1; i < argc; i++) { @@ -165,24 +173,24 @@ njs_get_options(njs_opts_t *opts, int argc, char** argv) p++; switch (*p) { + case '?': + case 'h': + (void) write(STDIN_FILENO, help, nxt_length(help)); + return ret; + case 'd': opts->disassemble = 1; break; + case 'v': case 'V': opts->version = 1; break; default: - fprintf(stderr, "Unknown argument: \"%s\"\n", argv[i]); - ret = NXT_ERROR; - - /* Fall through. */ - - case 'h': - case '?': - printf("Usage: %s [|-] [-dV]\n", argv[0]); - return ret; + fprintf(stderr, "Unknown argument: \"%s\" " + "try \"%s -h\" for available options\n", argv[i], argv[0]); + return NXT_ERROR; } } diff --git a/nxt/auto/os b/nxt/auto/os index 6726f0db..e4f6d26a 100644 --- a/nxt/auto/os +++ b/nxt/auto/os @@ -9,6 +9,7 @@ NXT_SYSTEM=`uname -s 2>/dev/null` case "$NXT_SYSTEM" in Linux) + nxt_define=NXT_LINUX . ${NXT_AUTO}define NXT_SYSTEM_VERSION=`uname -r 2>/dev/null` # Linux uname -p can return "unknown". NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null` diff --git a/nxt/nxt_unix.h b/nxt/nxt_unix.h new file mode 100644 index 00000000..bf45fd15 --- /dev/null +++ b/nxt/nxt_unix.h @@ -0,0 +1,23 @@ + +/* + * Copyright (C) Dmitry Volyntsev + * Copyright (C) NGINX, Inc. + */ + + +#ifndef _NXT_UNIX_H_INCLUDED_ +#define _NXT_UNIX_H_INCLUDED_ + +#if (NXT_LINUX) + +#ifdef _FORTIFY_SOURCE +/* + * _FORTIFY_SOURCE + * does not allow to use "(void) write()"; + */ +#undef _FORTIFY_SOURCE +#endif + +#endif /* NXT_LINUX */ + +#endif /* _NXT_UNIX_H_INCLUDED_ */