Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Last active February 9, 2019 07:28
Show Gist options
  • Save snipsnipsnip/d25defb978aecb89775f to your computer and use it in GitHub Desktop.
Save snipsnipsnip/d25defb978aecb89775f to your computer and use it in GitHub Desktop.
backtick.bat: poor man's xargs
@ruby^
-Ebinary:binary^
-e "args = STDIN.readlines.map(&:strip)"^
-e "abort 'empty args' if args.empty?"^
-e "cmd = ARGV.empty? ? ['type'] : ARGV"^
-e "ai = cmd.any? {|c| c.include?('{}') }"^
-e "cmds = ai ? args.map {|a| cmd.map {|z| z.gsub(/\{\}/, a).gsub(/@@/, '{}') } } : [cmd + args]"^
-e "cmds.each {|c| warn 'backtick: ' + c.join(' '); system(*c) || exit($?.to_i) }"^
-- %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment