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

protected grep from alias, join some sed commands and don't load profile if not needed #68

Closed
wants to merge 1 commit into from

Conversation

glhez
Copy link

@glhez glhez commented Aug 26, 2015

Hello,

I've pushed 3 commits:

  • A protection against grep alias; if you do alias grep='grep --color -Hn', then the $common_plugins local will contains line starting with (standard input):<line number>:.
  • An optimisation on sed, to not invoke it several times. This is better for Windows.
  • An optimisation on profile, which don't have to be loaded unless -P or --active-profiles is used.

Note: I used a trick of sed, which can remove the \n delimiter. eg: sed -e s/\n/\|/g does the same as tr '\n' '|'. This works on Git for Windows, did not test on a Linux bash.

@mosabua
Copy link
Collaborator

mosabua commented Aug 27, 2015

@glhez did you test this on Linux and Mac?

@glhez
Copy link
Author

glhez commented Aug 27, 2015

Yep. Tested on:

  • Linux 4.0.5-gentoo / bash: version 4.3.39(1)-release (x86_64-pc-linux-gnu)
  • Windows 7 Pro / bash: 4.3.39(3)-release (x86_64-pc-msys + git version 2.5.0.windows.1)

Don't have a Mac.

I've added two more commit:

  • You can replace new line with sed, but it is a bit more complicated than I though.
  • The second commit patch this case:
$ mvn v[TAB]
validate   verify <-- (phase)
$ mvn ver[TAB]
verify <-- phase
$ mvn vers[TAB]
versions: <-- goal

Now it display (here under linux):

$ mvn ver
verify     versions:  vertx: <-- phase + goal

Also, I think the elif [[ ${cur} == *:* ]] ; then can be completely done by the last else.

@glhez
Copy link
Author

glhez commented Jan 26, 2020

I mainly replaced old commit due to wrong mail being referenced. It is also rebase against master for all that matter.

…(rare) case of command being aliased, minimize shell invocation, don't read profile/maven file needlessly, ...)
@glhez
Copy link
Author

glhez commented May 2, 2020

I'm closing my PR because of the newly drastic change I've made ... and the fact they were never considered since 2015...

You may still read those:

  • I've prefixed cd by builtin like Use "builtin cd" instead of just "cd" #92
  • I've prefixed sed and grep by command.
  • I've used mapfile and shellcheck to the whole file; this avoid use of IFS and make the code easier to read (to me, at least)
  • I've used two function rather than a N variables and indirection
  • I fixed the way that the completion was reading pom / settings for profile even if it was not needed
  • I've applied a consistent indentation of two spaces and use a java-ish syntax (the foobar() { LF } thing)

@glhez glhez closed this May 2, 2020
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.

2 participants