~nilium/mtar

b6f794952aa5fd0c289671fb5145586488a463f3 — Noel Cower 4 years ago a901f80 v1.0.1
Handle bash <() redirection

There's probably a better way to detect these specifically, but since
mtar preserves symlinks by default, it's a special case.
1 files changed, 5 insertions(+), 1 deletions(-)

M mtar.go
M mtar.go => mtar.go +5 -1
@@ 366,10 366,14 @@ func addFile(w *tar.Writer, src, dest string, opts *FileOpts, allowRecursive boo
		hdr.Typeflag = tar.TypeDir
		hdr.Name = dest + "/"
	case st.Mode()&os.ModeSymlink == os.ModeSymlink:
		hdr.Typeflag = tar.TypeSymlink
		hdr.Name = dest
		link, err := os.Readlink(src)
		failOnError("cannot resolve symlink", err)
		if strings.HasPrefix(src, "/proc/self/fd/") && strings.HasPrefix(link, "pipe:[") && strings.HasSuffix(link, "]") { // Special case: <(proc) pipe
			needBuffer = true
			break
		}
		hdr.Typeflag = tar.TypeSymlink
		hdr.Linkname = link
	default:
		log.Print("skipping file: ", src, ": cannot add file")