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

<(command) in fish #4682

Closed
theScrabi opened this issue Jan 26, 2018 · 5 comments
Closed

<(command) in fish #4682

theScrabi opened this issue Jan 26, 2018 · 5 comments
Labels

Comments

@theScrabi
Copy link

Hello in bash there is this construct existing <( ). The stdout of the command inside the brackets is redirected, and a file descriptor is returned:

$ echo <(echo "hallo welt")
/dev/fd/63

So You can write constructs like this:

$ cat <(echo "hallo welt")
hallo welt

Is something like this possible with fish?

@faho
Copy link
Member

faho commented Jan 26, 2018

Fish has the psub command that writes its input to a file and prints the name of that file.

So you'd do

cat (echo "Hallo Welt" | psub)

See the documentation for psub.

@faho faho added the question label Jan 26, 2018
@theScrabi
Copy link
Author

That is cool :D, but it's a file and no pipe right?

@faho
Copy link
Member

faho commented Jan 26, 2018

Short answer: Yes.

Longer answer: By default, yes, but psub technically supports a flag to use a fifo instead. Only that has some issues so I wouldn't currently recommend using it (unless you can guarantee that your output will be smaller than the pipe buffer) - see #1040.

Any reason you want a pipe?

@theScrabi
Copy link
Author

I see.

@faho faho closed this as completed Jan 29, 2018
@theScrabi
Copy link
Author

theScrabi commented Jan 29, 2018

A pipe uses kernel buffer which

  1. Is faster
  2. May use up write cycles on an ssd
  3. When you try to pass passwords or keys /tmp might be unsave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants