Skip to content

improve compatibility and portability#8

Open
JaafarMehrez wants to merge 1 commit intoaaossa:mainfrom
JaafarMehrez:main
Open

improve compatibility and portability#8
JaafarMehrez wants to merge 1 commit intoaaossa:mainfrom
JaafarMehrez:main

Conversation

@JaafarMehrez
Copy link

This PR fixes some compatibility issues that prevented the script from working on systems with:

  1. Older Bash versions (3.2+, common on macOS)
  2. BSD date instead of GNU date (macOS default)
  3. Fish shell environments

The errors I was getting on macOS with Fish shell:

/ForkedRepo/git-activity/git-activity: line 73: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
gdate: invalid date ‘2025-12-13 3 2025-12-12 3 2025-12-11 6 2025-12-10 1 2025-12-09 7 2025-12-05 3 2025-12-04 4 2025-12-03 2 2025-11-27 3 2025-11-26 3 2025-11-25 2 2025-11-24 1 2025-11-23 1 2025-11-22 1 2025-11-18 2 2025-11-15 4 2025-11-13 8 2025-11-12 7 2025-11-11 4 2025-11-10 11 2025-11-08 8 2025-11-07 1 2025-10-31 2 2025-10-30 3 2025-10-25 6 2025-10-23 1 2025-10-22 3 2025-10-18 3 2025-10-15 6 2025-10-07 1 2025-10-01 3 2025-09-30 3 2025-09-29 3 2025-09-27 3 2025-09-26 8 2025-09-24 1 2025-09-22 2 2025-09-21 5 2025-09-20 2 2025-09-19 7 2025-09-18 2 2025-09-16 5 2025-09-15 3 2025-09-13 2 2025-09-08 1 2025-09-06 2 2025-09-05 4 2025-09-02 2 2025-08-29 4 2025-08-28 6 2025-08-27 2 2025-08-25 7 2025-08-24 12 2025-08-23 2 2025-08-21 8 2025-08-20 8 2025-08-19 3 2025-08-17 3 2025-08-15 1 2025-08-14 5 2025-08-13 5 2025-08-10 2 2025-08-09 6 2025-08-08 7 2025-08-07 1 2025-08-06 3 2025-08-05 1 2025-08-04 1 2025-08-03 2 2025-07-31 1 2025-07-25 2 2025-07-24 3 2025-07-23 1 2025-07-16 4 2025-06-25 6 2025-06-24 1 2025-03-27 2 2025-02-27 2 2025-02-26 3 2025-02-25 3 2025-02-24 4 2025-02-23 13:00 UTC’
/ForkedRepo/git-activity/git-activity: line 79: commits_per_day["${date_diff}"]: bad array subscript
       Jan Feb Mar  Apr May Jun  Jul Aug  Sep Oct Nov  Dec
/ForkedRepo/git-activity/git-activity: line 106: conditional binary operator expected
/ForkedRepo/git-activity/git-activity: line 106: syntax error near `commits_per_day["${key}"]'
/ForkedRepo/git-activity/git-activity: line 106: `    if [[ -v commits_per_day["${key}"] ]]; then'

The following changes are made:

  1. Replaced associative arrays with indexed arrays
  2. Improved date command compatibility
  3. Fixed array element existence checking

Testing

The script now works on

  1. macOS with default Bash 3.2 and BSD date
  2. Linux with GNU date and Bash 4+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments