Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Create commands for IO Redirection #4

Open
frenchy64 opened this Issue · 5 comments

3 participants

@frenchy64
Collaborator

Bash has plenty of IO redirection commands like < and <&-.

These could possibly be mapped to commands as such:

(redir :stdout
  (~java :classpath [@CLOJURE_JARS @VIMCLOJURE_JAR]
     :server true
     :main-class vimclojure.nailgun.NGServer
     :args @port))

A comparison to Windows IO redirection commands should also be made to try and create a set of stevedore scripts for both OS's.

@frenchy64 frenchy64 was assigned
@frenchy64
Collaborator

Here is a proposed solution.

(with-script-context [:default]
  (script
    (~with-redir [[:err :out]
                  [:out "file.txt" :append true]
                  [:err "err.txt"]
                  [[:out :err] "/dev/null"]]
      (echo "asfd")
      (echo "asfd")
      (echo "asfd"))))

=>

{
 echo "asdf"
 echo "asdf"
 echo "asdf"
} 1>&2 >>file.txt 2>err.txt &>/dev/null
@icylisper

How do pipes work ? echo "asdf" | something . with-redir can take a :pipe keyword

@frenchy64
Collaborator

Pipes are already in stevedore.

(with-script-context [:default]
  (script
    (pipe (echo "asfd")
          (grep "a")
          (echo))))

=>

echo asfd | grep a | echo

Does it make sense to keep the distinction between pipes and IO redirection?

@icylisper

Makes sense. with-redir is quite an useful macro to have

@hugoduncan
Owner

I would name it with-redirect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.