Skip to content

Instantly share code, notes, and snippets.

@minimum2scp
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save minimum2scp/9372662 to your computer and use it in GitHub Desktop.

Select an option

Save minimum2scp/9372662 to your computer and use it in GitHub Desktop.
nginx -V の configure argumentsをみやすくするワンライナー

nginx -V:

nginx version: nginx/1.4.6
built by gcc 4.8.2 (Debian 4.8.2-16) 
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-auth-pam --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-dav-ext-module --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-echo --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-upstream-fair --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/ngx_http_substitutions_filter_module

の configure arguments が見辛いので、rubyのワンライナーで整形する。 configure arguments 以降を Shellwords.split して1オプション1行で表示する。

nginx -V 2>&1 | ruby -rshellwords -pe 'gsub(/^(configure arguments:)\s*?(.+)$/){ $1 + "\n" + Shellwords.split($2).map{|opt| "  #{opt}"}.join("\n") }'

実行例:

% nginx -V 2>&1 | ruby -rshellwords -pe 'gsub(/^(configure arguments:)\s*?(.+)$/){ $1 + "\n" + Shellwords.split($2).map{|opt| "  #{opt}"}.join("\n") }'
nginx version: nginx/1.4.6
built by gcc 4.8.2 (Debian 4.8.2-16) 
TLS SNI support enabled
configure arguments:
  --with-cc-opt=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
  --with-ld-opt=-Wl,-z,relro
  --prefix=/usr/share/nginx
  --conf-path=/etc/nginx/nginx.conf
  --http-log-path=/var/log/nginx/access.log
  --error-log-path=/var/log/nginx/error.log
  --lock-path=/var/lock/nginx.lock
  --pid-path=/run/nginx.pid
  --http-client-body-temp-path=/var/lib/nginx/body
  --http-fastcgi-temp-path=/var/lib/nginx/fastcgi
  --http-proxy-temp-path=/var/lib/nginx/proxy
  --http-scgi-temp-path=/var/lib/nginx/scgi
  --http-uwsgi-temp-path=/var/lib/nginx/uwsgi
  --with-debug
  --with-pcre-jit
  --with-ipv6
  --with-http_ssl_module
  --with-http_stub_status_module
  --with-http_realip_module
  --with-http_addition_module
  --with-http_dav_module
  --with-http_geoip_module
  --with-http_gzip_static_module
  --with-http_image_filter_module
  --with-http_spdy_module
  --with-http_sub_module
  --with-http_xslt_module
  --with-mail
  --with-mail_ssl_module
  --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-auth-pam
  --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-dav-ext-module
  --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-echo
  --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/nginx-upstream-fair
  --add-module=/tmp/buildd/nginx-1.4.6/debian/modules/ngx_http_substitutions_filter_module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment