Skip to content

Commit f5492d7

Browse files
authored
Fix bake init bug, update getting started (#35)
* Fix bake init bug, update getting started * ShellCheck fixes
1 parent 84c5980 commit f5492d7

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,24 @@ Organizing code into libraries is recommended, so we're going to start off with
4444

4545

4646
```sh
47-
$ test -d test/lib || mkdir test/lib
48-
$ cat > test/lib/mylib.sh
47+
# Create a test folder to hold the bake libraries
48+
test -d test/lib || mkdir -p test/lib
49+
50+
# Create library with a bake task
51+
cat > 'test/lib/mylib.sh' <<'EOF'
4952
#!/usr/bin/env bash
5053
bake_task mylib:foo "The foo command just echo's its arguments"
5154
function mylib:foo () {
5255
echo "foo: args='$@'"
5356
}
54-
^D
57+
EOF
5558

56-
$ cat > Bakefile
59+
# Create Bakefile to include libraries
60+
cat > 'Bakefile' <<'EOF'
5761
#!/usr/bin/env bash
5862
bake_push_libdir $(bake_bakefile_dir)/test/lib
5963
bake_require mylib
60-
^D
64+
EOF
6165
```
6266

6367
Then run bake:
@@ -70,7 +74,7 @@ bake task [arg ...]
7074
mylib:foo The foo command just echo's its arguments
7175
7276
73-
$ bake foo this that
77+
$ bake mylib:foo this that
7478
foo: args='this that'
7579
```
7680

bake

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,19 +440,19 @@ function bake_inernal_help () {
440440
function bake_sorted_task_list () {
441441
(
442442
for task in "${!BAKE_TASKS[@]}"; do
443-
if ! bake_is_registered_subtask $task; then
444-
echo $task
443+
if ! bake_is_registered_subtask "$task"; then
444+
echo "$task"
445445
fi
446446
done;
447447
for task in "${!BAKE_SUPERTASKS[@]}"; do
448-
echo $task
448+
echo "$task"
449449
done
450450
) | sort -u
451451
}
452452

453453
function bake_sorted_subtask_list () {
454454
for task in "${!BAKE_SUBTASKS[@]}"; do
455-
echo $task
455+
echo "$task"
456456
done | sort -u
457457
}
458458

@@ -540,18 +540,17 @@ function bake_update () {
540540

541541
function bake_create_bakefile () {
542542
if [ ! -e "Bakefile" ]; then
543-
cat > "Bakefile" <<END
543+
cat > "Bakefile" <<'END'
544544
#!/usr/bin/env bash
545545
546546
# bake_require github.com/kyleburton/bake-recipes/docker/docker.sh
547547
548+
# Set default editor if not defined
549+
export EDITOR="${EDITOR:-vi}"
550+
548551
bake_task get-started "Get started by editing this Bakefile"
549552
function get-started () {
550-
if [ -n "$EDITOR" ]; then
551553
"$EDITOR" Bakefile
552-
else
553-
vim Bakefile
554-
fi
555554
}
556555
END
557556
fi

0 commit comments

Comments
 (0)