# Command line prefix (-p) parameter parsing

**URL:** <https://www.ruby-forum.com/t/command-line-prefix-p-parameter-parsing/222494>\
**Category:** NGINX\
**Created:** [August 30, 2012, 11:57am UTC](https://www.ruby-forum.com/t/command-line-prefix-p-parameter-parsing/222494 "2012-08-30T11:57:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 30, 2012, 11:57am UTC](https://www.ruby-forum.com/t/command-line-prefix-p-parameter-parsing/222494/1 "2012-08-30T11:57:34Z")

</div>

Hi,

I found that giving prefix as command line parameter and the prefix does  
not  
start with ‘/’ you append a ‘/’ to prefix (version: 1.2.3):

$ /usr/sbin/nginx -p prefix -c nginx.conf  
nginx: [emerg] open() “prefix/nginx.conf” failed (2: No such file or  
directory)

$ /usr/sbin/nginx -p prefix/ -c nginx.conf  
nginx: [emerg] open() “prefix//nginx.conf” failed (2: No such file or  
directory)

$ /usr/sbin/nginx -p /prefix -c nginx.conf  
nginx: [emerg] open() “/prefixnginx.conf” failed (2: No such file or  
directory)

$ /usr/sbin/nginx -p /prefix/ -c nginx.conf  
nginx: [emerg] open() “/prefix/nginx.conf” failed (2: No such file or  
directory)

I think you wanted to check the last character of prefix and not the  
first.  
So you should change nginx.c (line 839) from  
if (!ngx\_path\_separator(\*p)) {  
to  
if (len == 0 || !ngx\_path\_separator(p[len - 1])) {

Regards,  
Gabor

Posted at Nginx Forum:

> **[command line prefix (-p) parameter parsing](https://forum.nginx.org/read.php?2,230320,230320#msg-230320)**
>
> Hi, I found that giving prefix as command line parameter and the prefix does not start with '/' you append a '/' to prefix (version: 1.2.3): $ /usr/sbin/nginx -p prefix -c nginx.conf nginx: \[emerg\] open() "prefix/nginx.conf" failed (2: No...

---

<div class="post-metadata">

**Author:** ![leki75](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e47c2d/32.png) [@leki75](https://www.ruby-forum.com/u/leki75)\
**Post date:** [August 30, 2012, 12:01pm UTC](https://www.ruby-forum.com/t/command-line-prefix-p-parameter-parsing/222494/2 "2012-08-30T12:01:05Z")

</div>

Oh, I just found that you corrected this in 1.3.x version. Sorry for  
this  
redundant post.

Posted at Nginx Forum:

> **[Re: command line prefix (-p) parameter parsing](https://forum.nginx.org/read.php?2,230320,230321#msg-230321)**
>
> Hi, I found that giving prefix as command line parameter and the prefix does not start with '/' you append a '/' to prefix (version: 1.2.3): $ /usr/sbin/nginx -p prefix -c nginx.conf nginx: \[emerg\] open() "prefix/nginx.conf" failed (2: No...
