when developing Bash scripts, sometimes I'll run it in a Docker container, or on a VM to test it, but the ideal place for me to build out scripts is just on my local MacOS workstation.
When it comes to Bash scripts, this has never been a problem so far. However today I noticed that the date
command behaves differently between Linux and MacOS.
Example scenario, adding days to a date object:
Linux:
root@host$ date -d "$(date) 3 days" +%Y-%m-%d
2018-04-20
MacOS:
WS:tmp user$ date -d "$(date) 3 days" +%Y-%m-%d
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Doesn't work, so I have to reformat it:
WS:tmp user$ date -j -v +3d -f "%Y-%m-%d" $(date +%Y-%m-%d) +%Y-%m-%d`
2018-04-20
What a pain! A simple bash script and now I need a container or VM just to do some simple date manipulation.
This is making me feel like I'm shooting myself in the foot developing this way, and the whole reason I got a Mac was because it's much closer to a 'nix environment than any Windows version so I could do simple local development on it.
My question(s):
- Is this a licensing issue? It's my understanding that
date
is a GNU utility, so there shouldn't be any licensing issues. - Because I have not yet hit this issue until today, is there a known list of common apps that behave differently?
- Is it "bad practice" to develop some bash scripts on a Mac? I've been doing it for a while now and never hit an issue until now.
Your experience with this topic is appreciated, thank you!