Forum: NGINX add -h to nginx

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fcaa940f447c1c76afb8ee2448ba0461?d=identicon&s=25 Jérôme Loyet (Guest)
on 2009-03-24 14:28
(Received via mailing list)
Attachment: nginx-help.patch (1 KB)
Hello,

I attach a small patch which add the -h argument to nginx. As common
programs, this arg show the available options.

[root@wp0men04s /LIBRE/nginx/nginx-0.7.44]# ./objs/nginx -h
Usage: nginx [-h] [-v] [-V] [-t] [-c filename] [-g param] [-d basedir]

Options:
        -h           : list available command line options (this page)
        -v           : show version then exit
        -V           : show version and configure options then exit
        -c filename  : set conf file (default:
/usr/local/nginx/conf/nginx.conf)
        -g param     : set conf directive out of conf file

nginx version: nginx/0.7.44

Don't know if you're interested in such a patch. But the first time I
tried nginx I was kind of lost on where to find available options.

And I ask myself a question, why use those lines:
        p = "nginx version: " NGINX_VER CRLF;
        n = sizeof("nginx version: " NGINX_VER CRLF) - 1;

        if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) {
            return 1;
        }

instead of

        p = "nginx version: " NGINX_VER CRLF;

        if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
            return 1;
        }

Thanks
++ Jerome
Fcaa940f447c1c76afb8ee2448ba0461?d=identicon&s=25 Jérôme Loyet (Guest)
on 2009-03-24 14:37
(Received via mailing list)
Attachment: nginx-help.patch (1 KB)
Le 24 mars 2009 14:15, Jérôme Loyet <jerome@loyet.net> a écrit :
>        -v           : show version then exit
>        p = "nginx version: " NGINX_VER CRLF;
>        if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
>            return 1;
>        }
>

Sorry I sent the wrong version of the patch. The right version is
attached.
And in my previous question I meant:

 instead of

        p = "nginx version: " NGINX_VER CRLF;
        n = strlen(p);

        if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) {
            return 1;
        }
A50d1b69d837f1cabc58e46cbc866c94?d=identicon&s=25 Juan Fco. Giordana (Guest)
on 2009-03-24 15:15
(Received via mailing list)
Shouldn't -t and -d options also be explained?
Fcaa940f447c1c76afb8ee2448ba0461?d=identicon&s=25 Jérôme Loyet (Guest)
on 2009-03-24 16:22
(Received via mailing list)
Attachment: nginx-help.patch (1 KB)
My mistake about the forgotten "-t" explanation.

but as far as I read the last sources well (0.7.44) there is no -d
options.

# ./objs/nginx -d
2009/03/24 16:11:01 [emerg] 16808#0: invalid option: "-d"

# ./objs/nginx -v
nginx version: nginx/0.7.44

I've attached a new revision of the patch

++ Jerome

2009/3/24 Juan Fco. Giordana <juangiordana@gmail.com>:
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-03-25 11:31
(Received via mailing list)
On Tue, Mar 24, 2009 at 02:15:29PM +0100, J?r?me Loyet wrote:

>         p = "nginx version: " NGINX_VER CRLF;
>
>         if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
>             return 1;
>         }

Because strlen() finds a string length on run-time, scanning for
trailing
zero, while sizeof() return length of a known string on compile time.
For this reason I use strlen() only if it's really needed.

However, here are two notes:
1) modern compilers usually optimize such strlen()s to just sizeof()s,
2) this place is not time critical, so strlen() can be used.
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-03-25 11:33
(Received via mailing list)
On Tue, Mar 24, 2009 at 04:11:50PM +0100, J?r?me Loyet wrote:

> I've attached a new revision of the patch
Thank you.

Are any corrections regarding English part of the message:

-?            : this help
-h            : this help
-v            : show version then exit
-V            : show version and configure options then exit
-t            : test configuration and exit
-c filename   : set configuration file (default: ...)
-g directives : set global configuration directives out of conf file

?
This topic is locked and can not be replied to.