Last active
February 9, 2019 07:28
-
-
Save snipsnipsnip/d25defb978aecb89775f to your computer and use it in GitHub Desktop.
backtick.bat: poor man's xargs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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