|
Message-ID: <c2430b52ee88cd94ca942fcf9c567a99@smtp.hushmail.com> Date: Thu, 6 Sep 2012 09:35:33 +0200 From: magnum <john.magnum@...hmail.com> To: john-dev@...ts.openwall.com Subject: Re: bash completion on OSX On 6 Sep, 2012, at 7:50 , Frank Dittrich <frank_dittrich@...mail.com> wrote: > On 09/06/2012 12:50 AM, magnum wrote: >> Frank, >> >> While looking into getting bash completion working on OSX, I get this: >> >> $ . /usr/local/etc/bash_completion.d/john.bash_completion >> bash: /usr/local/etc/bash_completion.d/john.bash_completion: line 159: syntax error near unexpected token `(' >> bash: /usr/local/etc/bash_completion.d/john.bash_completion: line 159: ` -?(-)f?(o|or|orm|orma|ormat)+(=|:)dynamic*)' >> > > Please post the output of > $ shopt -p extglob The answer is "shopt -u extglob" in both versions. > Looks like bash's extended pattern matching features are not enabled on OSX. > > The requirement is documented close to the begin of the script: > > # This bash completion script requires bash version >= 4, > # and extended pattern matching features enabled. If > # shopt -p extglob > # prints > # shopt -s extglob > # then the extended pattern matching features enabled. If this command > # prints > # shopt -u extglob > # then they are disabled. Now I feel like a dork :) > May be I should add a similar comment close to the first syntax error > that occurs when extended pattern matching is disabled. > I do not suggest enabling it, because I don't know what negative side > effects it would have. > > The correct solution for the problem is not to hard code all the > possible abbreviations of individual options. > Instead, I should create a look-up table which maps all unique > abbreviated option names to their long names, then use the long names > instead of pattern which might not be supported in all environments. Would it still need bash >=4? The first file sourced for git completion has this: # Check for recent enough version of bash. bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.} if [ $bmajor -gt 4 ] || [ $bmajor -eq 4 -a $bminor -ge 1 ]; then [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \ . "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" if shopt -q progcomp && [ -r /opt/local/share/bash-completion/bash_completion ]; then # Source completion code. . /opt/local/share/bash-completion/bash_completion fi fi This suggests git even needs >= 4.1. But that completion works so maybe it does not need extglob. > Can you test if bash's syntax check complains about > --restore|--status) > as well (if you comment out or delete the > -?(-)f?(o|or|orm|orma|ormat)+(=|:)*) > and subsequent lines? bash: _get_comp_words_by_ref: command not found sed: 1: "{ s#^ *\(--[a-z-]*=\?\( ...": bad flag in substitute command: '}' This error is run-time (happens when I press TAB). Actually, I now enabled git completion which apparently in turn enables globbing. After that, sourcing the pristine john completion file works fine, but I now get a similar run-time error: bash-4.2$ ../run/john[TAB] sed: 1: "{ s#^ *\(--[a-z-]*=\?\( ...": bad flag in substitute command: '}' magnum
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.