Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dd functionality #2

Open
ellcs opened this issue Jun 21, 2017 · 1 comment
Open

Support dd functionality #2

ellcs opened this issue Jun 21, 2017 · 1 comment

Comments

@ellcs
Copy link

ellcs commented Jun 21, 2017

Error: No binding for 'dd'. Did you mean 'cd'?
dd
^-

I just assume that every unix program needs it's own binding. Where do add a binding and how do i write one?

Cheers!

@mdr
Copy link
Owner

mdr commented Jun 21, 2017

I just assume that every unix program needs it's own binding

Yeah, the intention is that Mash should provide built-in support for most standard Unix functionality, including programs like dd, although it might end up with a different interface than the traditional command (dd actually being a good example that it has different argument convention to most programs).

Where do add a binding and how do i write one?

At the moment, for standard lib functions, they are written in Scala. There's an example binding to open in src/main/scala/com/github/mdr/mash/ns/os/OpenFunction.scala

You could also write a dd binding in Mash, as a user function. A simple one might look like:

def dd (in="/dev/stdin") (out="/dev/stdout") (blockSize=512) (count=1) = 
  !!{dd "if=$in" "of=$out" "bs=$blockSize" "count=$count"}

(And if you just want to run the dd executable, you can also do that using the "mish" subsyntax, e.g. by prepending an ! at the start: !dd if=/dev/urandom of=myrandom bs=100 count=1)

@mdr mdr changed the title Can not use dd out of the box. Support dd functionality Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants