Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change-log still needs some fixes. #337

Closed
hemanth opened this issue Mar 20, 2015 · 10 comments
Closed

change-log still needs some fixes. #337

hemanth opened this issue Mar 20, 2015 · 10 comments

Comments

@hemanth
Copy link
Collaborator

hemanth commented Mar 20, 2015

/usr/local/bin/git-changelog: line 230: local: -A: invalid option
local: usage: local name[=value] ...

ERROR:  Specified start-tag does not exist!

@spacewander @chernjie Noticing this?

local -A is not working on:

Darwin Apples-Macintosh.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
@yogin
Copy link

yogin commented Mar 25, 2015

Same issue here running on a mac.

From the bash man pages, local uses the same options as declare:

Here's the list of supported options under Ubuntu:

   declare [-aAfFgilnrtux] [-p] [name[=value] ...]
       typeset [-aAfFgilnrtux] [-p] [name[=value] ...]
              Declare variables and/or give them attributes.  If no names are given then display the values of variables.  The -p option will display the attributes and values of each name.  When -p is used with name arguments, additional options, other than -f and
              -F,  are  ignored.   When  -p is supplied without name arguments, it will display the attributes and values of all variables having the attributes specified by the additional options.  If no other options are supplied with -p, declare will display the
              attributes and values of all shell variables.  The -f option will restrict the display to shell functions.  The -F option inhibits the display of function definitions; only the function name and attributes are printed.  If the extdebug shell option is
              enabled using shopt, the source file name and line number where the function is defined are displayed as well.  The -F option implies -f.  The -g option forces variables to be created or modified at the global scope, even when declare is executed in a
              shell function.  It is ignored in all other cases.  The following options can be used to restrict output to variables with the specified attribute or to give variables attributes:
              -a     Each name is an indexed array variable (see Arrays above).
              -A     Each name is an associative array variable (see Arrays above).
              -f     Use function names only.
              -i     The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION above) is performed when the variable is assigned a value.
              -l     When the variable is assigned a value, all upper-case characters are converted to lower-case.  The upper-case attribute is disabled.
              -n     Give each name the nameref attribute, making it a name reference to another variable.  That other variable is defined by the value of name.  All references and assignments to name, except for changing the -n attribute itself, are  performed  on
                     the variable referenced by name's value.  The -n attribute cannot be applied to array variables.
              -r     Make names readonly.  These names cannot then be assigned values by subsequent assignment statements or unset.
              -t     Give each name the trace attribute.  Traced functions inherit the DEBUG and RETURN traps from the calling shell.  The trace attribute has no special meaning for variables.
              -u     When the variable is assigned a value, all lower-case characters are converted to upper-case.  The lower-case attribute is disabled.
              -x     Mark names for export to subsequent commands via the environment.

And the list of supported options on OSX:

     declare [-afFirtx] [-p] [name[=value] ...]
       typeset [-afFirtx] [-p] [name[=value] ...]
              Declare variables and/or give them attributes.  If no names are given then display the values of variables.  The -p option will display the attributes and values of each name.  When -p is used, additional options are ignored.  The
              -F  option  inhibits  the display of function definitions; only the function name and attributes are printed.  If the extdebug shell option is enabled using shopt, the source file name and line number where the function is defined
              are displayed as well.  The -F option implies -f.  The following options can be used to restrict output to variables with the specified attribute or to give variables attributes:
              -a     Each name is an array variable (see Arrays above).
              -f     Use function names only.
              -i     The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION ) is performed when the variable is assigned a value.
              -r     Make names readonly.  These names cannot then be assigned values by subsequent assignment statements or unset.
              -t     Give each name the trace attribute.  Traced functions inherit the DEBUG and RETURN traps from the calling shell.  The trace attribute has no special meaning for variables.
              -x     Mark names for export to subsequent commands via the environment.

              Using `+' instead of `-' turns off the attribute instead, with the exception that +a may not be used to destroy an array variable.  When used in a function, makes each name local, as with the local command.  If a variable name  is
              followed by =value, the value of the variable is set to value.  The return value is 0 unless an invalid option is encountered, an attempt is made to define a function using ``-f foo=bar'', an attempt is made to assign a value to a
              readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see Arrays above), one of the names is not a valid shell variable name, an attempt  is  made  to  turn  off
              readonly status for a readonly variable, an attempt is made to turn off array status for an array variable, or an attempt is made to display a non-existent function with -f.

Bash versions used:

OSX Bash version:

$ bash --version
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.

Ubuntu Bash version:

$ bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

@spacewander
Copy link
Collaborator

Hi.
I have discovered a workaround for associative array in bash 3:
http://stackoverflow.com/questions/688849/associative-arrays-in-shell-scripts/4444841#4444841

I will try to use it in git-changelog.
However, neither of my machines has bash 3.
Will someone be willing to test it when it is finished?

@hemanth
Copy link
Collaborator Author

hemanth commented Apr 15, 2015

@spacewander Go ahead, I can test those on mac.

@chernjie
Copy link
Contributor

@markeissler from #325, any suggestions on how to fix the local -A associative array issue?

@markeissler
Copy link
Contributor

Assoc arrays are only available in bash as of v4. This was written and tested on OSX...but then I've had a newer version of bash installed via homebrew forever. My bad.

@hemanth I can work around it by faking associative arrays but first question is: does this project want to continue to support bash less than v4? I don't know any OSX devs that don't have bash upgraded via homebrew or macports, etc.. On the other hand, since OSX still (!) ships with bash 3.2 maybe it should be supported?

@markeissler
Copy link
Contributor

I'm going ahead and working on a fix for this.

@spacewander
Copy link
Collaborator

@markeissler
Since you plan to deal with this issue, I decide to lay aside my work.
May you good luck!

In addition, I think the compatible support of bash 3 is useful, since many OSX users don't have a plan to update their bash to higher version.

@chernjie
Copy link
Contributor

@markeissler awesome! Thank you!

Let me know if you need any help for testing.

@hemanth
Copy link
Collaborator Author

hemanth commented Apr 17, 2015

I would also vote for compatible support of bash 3.

Looks like @markeissler has already done a PR.

@markeissler
Copy link
Contributor

I'd obviously appreciate any additional testing by others. I have tested on OSX with the installed bash 3 and also bash 4 (installed via homebrew).

markeissler added a commit to markeissler/git-extras that referenced this issue Apr 24, 2015
Removed dependency on real associative arrays, which are not
support previous to bash 4.
hemanth added a commit that referenced this issue Apr 25, 2015
Fix git-changelog for compatibility for bash<4. Fixes #337, #338
tardypad pushed a commit to tardypad/git-extras that referenced this issue Jul 13, 2016
Removed dependency on real associative arrays, which are not
support previous to bash 4.
tardypad pushed a commit to tardypad/git-extras that referenced this issue Jul 13, 2016
Removed dependency on real associative arrays, which are not
support previous to bash 4.
tardypad pushed a commit to tardypad/git-extras that referenced this issue Jul 13, 2016
Fix git-changelog for compatibility for bash<4. Fixes tj#337, tj#338
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

No branches or pull requests

5 participants