Nginx init.d script not filtering out comments correctly when awk-ing for the PID #35

Merged
merged 1 commit into from Apr 27, 2013

Conversation

Projects
None yet
2 participants
@tjasko
Contributor

tjasko commented Apr 27, 2013

When you declare the PID file in /etc/nginx/nginx.conf file like this:

# set the pid file of Nginx
pid /var/run/nginx.pid;

The code (PID=$(awk -F'[ ;]' '/[^#]pid/ {print $2}' /etc/nginx/nginx.conf)) getting the PID will include the comment (even though it excludes all other comments) making $PID output as follows:

set
/var/run/nginx.pid

I changed the variable to be set with awk -F'[ ;]' '$1 !~ /^#/ && /pid/ {print $2}' /etc/nginx/nginx.conf and now it is working correctly when someone includes "pid" in any comment above.

gplessis added a commit that referenced this pull request Apr 27, 2013

Merge pull request #35 from tjasko/master
Nginx init.d script not filtering out comments correctly when awk-ing for the PID

(Thanks @tjasko)

@gplessis gplessis merged commit b80dbfc into gplessis:master Apr 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment