about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-02-14 15:10:09 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2016-02-14 15:10:09 +0100
commit2f00c5b600d7222ed9093718025a06f29d04d690 (patch)
treed79dd99f7e7ed55c253f07d76d27c5e8f6a33614
parent23fdbc8400fc01e977753bc357ec9f4679a60290 (diff)
downloadarr-2f00c5b600d7222ed9093718025a06f29d04d690.tar.gz
arr-2f00c5b600d7222ed9093718025a06f29d04d690.tar.xz
arr-2f00c5b600d7222ed9093718025a06f29d04d690.zip
add custom joiner
-rwxr-xr-xarr13
1 files changed, 9 insertions, 4 deletions
diff --git a/arr b/arr
index 8d5ba5a..ae312d4 100755
--- a/arr
+++ b/arr
@@ -8,10 +8,11 @@
 
 USAGE = <<'EOF'
 Usage: arr [-0] [-P|-p PADDING] EXPR [FILES...]
-  EXPR   ::= FIELDS (("|" CHAR | "*") FIELDS)*  # | split on char, * split bytes
-  FIELDS ::= "~"? FIELD ("," FIELD)*            # ~ negates
-  FIELD  ::= "-"? "\d"+                         # negative fields count from back
-           | ("-"? "\d"+)? ":" ("-"? "\d"+)?    # range ends default to 1:-1
+  EXPR   ::= FIELDS (("|" CHAR | "*") FIELDS)* ("&" CHAR)?
+                     # | split on char, * split bytes, & join with char
+  FIELDS ::= "~"? FIELD ("," FIELD)*          # ~ negates
+  FIELD  ::= "-"? "\d"+                       # negative fields count from back
+           | ("-"? "\d"+)? ":" ("-"? "\d"+)?  # range ends default to 1:-1
 EOF
 
 require 'strscan'
@@ -70,6 +71,10 @@ def fmt(ss, d)
     end
   }
 
+  if ss.scan(/\&(.)/)
+    last_split = ss[1]
+  end
+
   unless ss.scan(/\}/)
     abort "parse error at #{ss.inspect}"
   end