Bash-it / bash-it

A community Bash framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Print such error after every command: "bash: /usr/bin/grep: No such file or directory"

pffang opened this issue · comments

Expected behavior

No error

Current behavior

Print such error after every command:
"bash: /usr/bin/grep: No such file or directory"

Possible solution

I checked the scripts, It may caused by the below function in .bash_it/lib/utilities.bash

Outputs a full path of the grep found on the filesystem

function _bash-it-grep() {
	: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
	printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}"
}

# Runs `grep` with extended regular expressions
function _bash-it-egrep() {
	: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
	"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
}

On my system, type -p grep print nothing.
type -a grep print like below:

grep is aliased to `grep --color=auto'
grep is /bin/grep

Workaround:
add below line in .bashrc
export BASH_IT_GREP='/bin/grep'

I think the better solution is to change type -p to type -P.

Context

No response

Steps to reproduce

On Ubuntu 20.04 latest update.
after updated to v3.0.1,
"bash: /usr/bin/grep: No such file or directory" is printed after every command.

Bash-it version

Version type: stable Current tag: v3.0.1

List of enabled plugins, themes and aliases

null

Bash version

GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

Operating system and version

Ubuntu 20.04

bash-it doctor output

# How to get: bash-it doctor

Your ~/.bashrc

Cannot share due to privacy.

Notes

No response

Hi @pffang, I have merged a fix now, can you try out the latest master and see if it's fixed?

@NoahGorny Works fine.