You Know You Are Trying to Do Too Much in a Bash One-Liner When …

find ~/bazel/src/main/webapp/lib -type f | grep -v "lib/deps/" | grep -v "lib/ext/" | grep -v "XG_MessageCatalog_" | xargs -I{} -L1 sh -c "echo {}; phpcs -d memory_limit=1024M -p -n -s --standard=/Users/bakert/Desktop/BazelCodingStandard {}"

Edit: Better:

#!/bin/env ruby

BAZEL_HOME = '/Users/bakert/bazel'
STANDARD_PATH = '/Users/bakert/Desktop/BazelCodingStandard'
VERBOSE = false

def main
  exclude_patterns = [ /XG_MessageCatalog_/, /\/lib\/deps\//, /\/lib\/ext\// ]
  files = Dir.glob("#{BAZEL_HOME}/src/main/webapp/**/*").reject do |f|
    exclude_patterns.any? { |p| f.match(p) } \
      || ! File.file?(f) \
      || File.extname(f) != '.php'
  end
  files.each do |f|
    puts f if VERBOSE
    print %x[phpcs -d memory_limit=1024M -n -s --standard=#{STANDARD_PATH} #{f}]
  end
end

main

One Reply to “You Know You Are Trying to Do Too Much in a Bash One-Liner When …”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.