Closed Spaxe closed 8 years ago
I think you should not replace aliases with variables. Instead try to conditionally define aliases, like:
if runner_is_defined gdate; then
alias runner_time='gdate +%s%3N'
else
alias runner_time='date +%s%3N'
fi
Same for readlink
in bin/runner
. Maybe runner_readlink
? Also same for runner_log
, but instead conditionally define a function.
I'd also use full paths to mac binaries (there was a comment in SO, that gdate
is an alias to /usr/local/opt/coreutils/libexec/gnubin/date
), maybe there's some edge case where gdate
means something not from coreutils.
P.S. Also use double brackets, because it's a useful bashism with additional features, variable auto-escaping is one of them.
Issue #4
The fullpath to homebrew binaries is version dependent:
$ greadlink `which greadlink`
../Cellar/coreutils/8.24/bin/greadlink
So I use the homebrew convention /usr/local/bin/...
instead.
What do you mean by double brackets? Sorry I'm not really well-versed in bash.
The alias should cover runner_log
.
I mean using double bracket notation for conditional expressions:
[[ $1 == foo ]]
Also I wouldn't re-alias date
, because user expects date
to be whatever it is (a lot of mac scripts could depend on it), and now it's GNU date
, and afaik these bash aliases are visible to all child programs, so no.
Just wrap local functions/aliases declarations into conditions, and declare either variant depending on the OSX check.
Alias is easy enough to fix :]
Double bracket notation on the GNU detection seems to not work; maybe you know what to do.
$ runner
/Users/spaxe/dev/bash-task-runner/bin/runner: line 5: conditional binary operator expected
/Users/spaxe/dev/bash-task-runner/bin/runner: line 5: syntax error near `--version'
/Users/spaxe/dev/bash-task-runner/bin/runner: line 5: `if [[ readlink --version > /dev/null 2>&1 ]]; then'
I've left the conditionals for now.
@Spaxe haha, no, double brackets ain't meant to be used like that. Merged your changes, seems OK for me.
Good news! I'll wait for the npm update - then I can put my version away :D
Done.
P.S. And thanks for the contribution!
Thanks for maintaining this script!
This patch enables bash-task-runner to run on Mac OS X (tested on 10.11.1 OS X El Capitan).
Mac users should be able to use it out of the box after installing the two dependencies via homebrew or similar.
Please review. :]