From 788014517381f4bc3c97120ffe57505616115634 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Tue, 5 Dec 2017 22:20:32 +0200 Subject: [PATCH] Second implementation. This is slightly more hackish, but offers more invocation options (the main one being `curl http://host/bundle | sh`). --- .gitignore | 1 - Makefile | 9 +++------ shellscript | 5 +++-- test.bats | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 6fbbce7..709010d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ hello -hello.uu bundle output diff --git a/Makefile b/Makefile index 94dfeba..0d374a1 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ -bundle: hello.uu shellscript - cat shellscript hello.uu > bundle - chmod 755 bundle - -hello.uu: hello - uuencode hello output > hello.uu +bundle: hello shellscript + awk '{if ($$0 == "INSERT BINARY HERE") {system("uuencode -m hello output")} else {print $$0}}' shellscript > bundle + chmod +x bundle hello: hello.c gcc -o hello hello.c diff --git a/shellscript b/shellscript index 3ce647f..38053ba 100644 --- a/shellscript +++ b/shellscript @@ -1,5 +1,6 @@ #!/bin/sh set -eu -uudecode "$0" +uudecode << EOF +INSERT BINARY HERE +EOF ./output -exit diff --git a/test.bats b/test.bats index 2173631..528936f 100644 --- a/test.bats +++ b/test.bats @@ -18,7 +18,6 @@ setup () { } @test 'cat bundle | sh' { - skip "This will fail" run sh -c 'cat bundle | sh' [ "$output" = "Hello world." ] [ "$status" -eq 0 ] -- GitLab