Skip to content
Myr

proxy_unix.go

This file

Path

src/proxy_unix.go

41 lines · 690 bytes · Go

Last changed by

Not known.

History of this file

Take it

1//go:build !windows23package fzf45import (6	"io"7	"os"89	"golang.org/x/sys/unix"10)1112func sh(bash bool) (string, error) {13	if bash {14		return "bash", nil15	}16	return "sh", nil17}1819func mkfifo(path string, mode uint32) (string, error) {20	return path, unix.Mkfifo(path, mode)21}2223func withOutputPipe(output string, task func(io.ReadCloser)) error {24	outputFile, err := os.OpenFile(output, os.O_RDONLY, 0)25	if err != nil {26		return err27	}28	task(outputFile)29	outputFile.Close()30	return nil31}3233func withInputPipe(input string, task func(io.WriteCloser)) error {34	inputFile, err := os.OpenFile(input, os.O_WRONLY, 0)35	if err != nil {36		return err37	}38	task(inputFile)39	inputFile.Close()40	return nil41}