diff --git a/Makefile b/Makefile index a07a825..2b0b657 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +SHELL := /bin/bash .DEFAULT_GOAL := ci TARGETS := $(shell ls scripts) .PHONY: run clean $(TARGETS) @@ -6,14 +7,8 @@ $(TARGETS): ./scripts/$@ run: - make build - rm -f 16-bundle-manifest.bundle - rm -rf /tmp/bashful.* - ./dist/bashful bundle example/16-bundle-manifest.yml - ./16-bundle-manifest.bundle - - # go run main.go task.go config.go screen.go download.go log.go \ - # run example/16-bundle-manifest.yml + go run main.go task.go config.go screen.go download.go log.go archive.go \ + run example/00-demo.yml examples: clean build ./dist/bashful run example/00-demo.yml diff --git a/archive.go b/archive.go index 23fd9cb..0316c9e 100644 --- a/archive.go +++ b/archive.go @@ -3,6 +3,7 @@ package main import ( "archive/tar" "compress/gzip" + "errors" "io" "os" "path/filepath" @@ -81,7 +82,8 @@ func (archiver *archive) Archive(srcPath string, preservePath bool) error { fields := strings.Split(srcPath, string(os.PathSeparator)) for idx := range fields { path := strings.Join(fields[:idx+1], string(os.PathSeparator)) - archiver.addTarFile(path, path) + err := archiver.addTarFile(path, path) + checkError(err, "Unable to archive file") } } @@ -89,6 +91,9 @@ func (archiver *archive) Archive(srcPath string, preservePath bool) error { } func (archiver *archive) addTarFile(path, name string) error { + if strings.Contains(path, "..") { + return errors.New("Path cannot contain a relative marker of '..': " + path) + } fi, err := os.Lstat(path) if err != nil { return err diff --git a/example/.bashful/downloads/compile-something.sh b/example/.bashful/downloads/compile-something.sh new file mode 100755 index 0000000..ac3f3de --- /dev/null +++ b/example/.bashful/downloads/compile-something.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# From: https://codegolf.stackexchange.com/questions/30322/make-it-look-like-im-working + +collect() +{ + while read line;do + if [ -d "$line" ];then + (for i in "$line"/*;do echo $i;done)|shuf|collect + echo $line + elif [[ "$line" == *".h" ]];then + echo $line + fi + done +} + +sse="$(awk '/flags/{print;exit}'