Skip to content

Instantly share code, notes, and snippets.

@icy
Last active March 13, 2020 06:50
Show Gist options
  • Save icy/99ba9659b307c8e8ed3750dde1a1c971 to your computer and use it in GitHub Desktop.
Save icy/99ba9659b307c8e8ed3750dde1a1c971 to your computer and use it in GitHub Desktop.
Makefile-vs-Bash.sh
## Makefile
.PHONY: default
default:
@echo This is default
.PHONY: tests
tests:
@echo We have tests. All tests passed.
.PHONY: failing
failing:
@echo We have tests. All tests failed.
.PHONY: ifthen
ifthen:
@if foo; then \
echo "This is foo"; \
else \
echo "This is bar" ; \
fi
.PHONY: all
all: tests ifthen failing
@echo We have all. All failed.
## Bash file
#!/usr/bin/env bash
default() { echo "This is default"; }
tests() { echo "We have tests. All tests passed."; }
failing() { echo "We have tests. All tests failed."; }
ifthen() { if foo; then echo "This is foo"; else echo "This is bar"; fi; }
all() { tests && ifthen && failing && echo "We have tests. all tests failed"; }
unknown_command() { echo "Unknown command"; }
"${@:-unknown_command}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment