Comments (3)
So from my basic understanding (just going to write this out to ensure I'm on the right page) this isn't an sh feature and is something found in other shells like bash. It requires creating a pipe containing the string's contents and passing the file descriptor of that pipe as an argument to the diff
subprocess. For this to work in dax there would need to be a way in Deno of creating named pipes and then providing those to subprocesses as arguments (it's something that's been discussed in the past and I think we could do it).
Looking at diff
, it seems like there isn't a way to just provide it two strings as arguments. This is the best I can do in this scenario for the time being, which is slightly unfortunate:
async function diff(a: string, b: string) {
async function makeTempFile() {
const filePath = await Deno.makeTempFile();
return $.path(filePath);
}
const [temp1, temp2] = await Promise.all([makeTempFile(), makeTempFile()]);
try {
await Promise.all([temp1.writeText(a), temp2.writeText(b)]);
await $`diff ${temp1} ${temp2}`;
} finally {
await Promise.all([temp1.remove(), temp2.remove()]);
}
}
const a = "12345"
const b = "23456"
await diff(a, b);
from dax.
Thank you for sharing your understanding. You are correct that this feature isn't native to sh
and is more commonly found in shells like bash
. I appreciate your insight into the potential solution for Dax, and I agree that having the capability to create named pipes in Deno and passing them as arguments to subprocesses would be a valuable addition.
from dax.
I was wondering if it would be possible to instead set fds
ourselves. For example, imagemagick lets you run something like convert fd:3 fd:4
to take data from pipe 3 and 4 to use. Here's an example of it for a different project in node.
from dax.
Related Issues (20)
- Logging object as argument should not print [object Object]
- Upgrade dependency deno_task_shell to 0.14.2
- Merged streams make it unable to access streams HOT 1
- Panic on stderr redirect
- Make it easier to pipe to files HOT 3
- Patch for deprecation warnings in console/utils.ts HOT 2
- Redesign command and internal streams
- Ability to cancel a request HOT 1
- Support for subshells breaks escaped parentheses HOT 1
- Rename `PathRef` to `Path`
- Support providing a `CommandBuilder` to a template literal expr HOT 1
- built-in 'cat' command does not work with absolute paths
- Add `.linesIter()`
- Support glob expansion
- Path - Copy dir recursive
- Strict typing for arguments HOT 1
- Strange issue when upgrading Deno HOT 2
- $.prompt doesn't support utf-8? HOT 1
- add command for `tar`
- imagemagick hangs 😞
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dax.