]> gitweb.factorcode.org Git - factor.git/commitdiff
backticks: adding backtick syntax experiment.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 18 Apr 2015 00:40:12 +0000 (17:40 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 18 Apr 2015 00:40:12 +0000 (17:40 -0700)
extra/backticks/authors.txt [new file with mode: 0644]
extra/backticks/backticks-docs.factor [new file with mode: 0644]
extra/backticks/backticks.factor [new file with mode: 0644]
extra/backticks/summary.txt [new file with mode: 0644]

diff --git a/extra/backticks/authors.txt b/extra/backticks/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/backticks/backticks-docs.factor b/extra/backticks/backticks-docs.factor
new file mode 100644 (file)
index 0000000..df6b135
--- /dev/null
@@ -0,0 +1,12 @@
+USING: help.markup help.syntax io.encodings.utf8 strings ;
+IN: backticks
+
+HELP: `
+{ $syntax "` command [args]`" }
+{ $description "Runs the specified command and captures the output as a " { $link utf8 } " encoded " { $link string } "." }
+{ $examples
+    { $unchecked-example
+        "` ls -l`"
+        "total 45\ndrwxrwxr-x+ 61 root  admin  2074 Apr  8 22:58 Applic..."
+    }
+} ;
diff --git a/extra/backticks/backticks.factor b/extra/backticks/backticks.factor
new file mode 100644 (file)
index 0000000..eeb5f17
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2015 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+USING: fry io io.encodings.utf8 io.launcher multiline sequences
+unicode.categories ;
+IN: backticks
+
+SYNTAX: `
+    "`" parse-multiline-string [ blank? ] trim
+    '[ _ utf8 [ contents ] with-process-reader ]
+    append! ;
diff --git a/extra/backticks/summary.txt b/extra/backticks/summary.txt
new file mode 100644 (file)
index 0000000..a3a11c5
--- /dev/null
@@ -0,0 +1 @@
+Backtick process syntax