openresty / echo-nginx-module

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
http://wiki.nginx.org/NginxHttpEchoModule
BSD 2-Clause "Simplified" License
1.17k stars 255 forks source link

echo "-U" doesn't echo anything. #53

Closed amdei closed 8 years ago

amdei commented 8 years ago

This configuration: location /t { echo -n "U"; echo -n "-U"; } produces only "U" as output, while I expect it to produce "U-U".

At the same time this configuration: location /t { echo -n "-"; } produces expected "-".

Looking at the debugger output, seems that anything started with "-" treated as option, even in commas and even if it is not a valid option.

Is it bug or feature? Is there a way to overcome such behavior without introducing variable?

agentzh commented 8 years ago

@amdei Try echo -n -- -U.

amdei commented 8 years ago

@agentzh Yep, it works.

agentzh commented 8 years ago

@amdei Well, this is documented.

amdei commented 8 years ago

@agentzh Yep, documented. Just didn't expect I should be careful with anything started with dash, even if it is not a valid option.

agentzh commented 8 years ago

@amdei Sometimes the user may make a typo in the valid option, and it's better to complain than sorry. Also, we may add new options in the future so it's important to be forward compatible.