aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--njs/njs_core.h1
-rw-r--r--njs/njs_shell.c26
-rw-r--r--nxt/auto/os1
-rw-r--r--nxt/nxt_unix.h23
4 files changed, 42 insertions, 9 deletions
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 <nxt_auto_config.h>
+#include <nxt_unix.h>
#include <nxt_types.h>
#include <nxt_clang.h>
#include <nxt_alignment.h>
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"
+ " <filename> | - 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 [<file>|-] [-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_ */