Welcome! Log In Create A New Profile

Advanced

[njs] Shell: passing original filename to parser.

Dmitry Volyntsev
February 28, 2019 08:10AM
details: https://hg.nginx.org/njs/rev/21925caaa3c5
branches:
changeset: 813:21925caaa3c5
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Feb 28 15:32:15 2019 +0300
description:
Shell: passing original filename to parser.

diffstat:

njs/njs_shell.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 4276436234aa -r 21925caaa3c5 njs/njs_shell.c
--- a/njs/njs_shell.c Tue Feb 26 10:19:14 2019 +0800
+++ b/njs/njs_shell.c Thu Feb 28 15:32:15 2019 +0300
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include <locale.h>

#include <readline.h>
@@ -195,6 +196,7 @@ static njs_console_t njs_console;
int
main(int argc, char **argv)
{
+ char path[MAXPATHLEN], *p;
nxt_int_t ret;
njs_opts_t opts;
njs_vm_opt_t vm_options;
@@ -215,14 +217,19 @@ main(int argc, char **argv)
nxt_memzero(&vm_options, sizeof(njs_vm_opt_t));

if (!opts.quiet) {
- if (opts.file != NULL) {
- vm_options.file.start = (u_char *) opts.file;
- vm_options.file.length = strlen(opts.file);
- nxt_file_basename(&vm_options.file, &vm_options.file);
+ if (opts.file == NULL) {
+ p = getcwd(path, sizeof(path));
+ if (p == NULL) {
+ fprintf(stderr, "getcwd() failed:%s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }

- } else {
- vm_options.file = nxt_string_value("shell");
+ memcpy(path + strlen(path), "/shell", sizeof("/shell"));
+ opts.file = path;
}
+
+ vm_options.file.start = (u_char *) opts.file;
+ vm_options.file.length = strlen(opts.file);
}

vm_options.init = !opts.interactive;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Shell: passing original filename to parser.

Dmitry Volyntsev 292 February 28, 2019 08:10AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 153
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready