Found this function in my bashrc under user defined aliases; I dont remember adding it?

Artemis_Mystique@lemmy.ml to Linux@lemmy.ml – 43 points –

I don't know bash scripting

if [ -d ~/.bashrc.d ]; then
	for rc in ~/.bashrc.d/*; do
		if [ -f "$rc" ]; then
			. "$rc"
		fi
	done

I asked chatgpt and it said this is non standard? There is no bashrc.d directory on my home folder, I have uncommented the lines for now but dont know if this is benign or malignant

22

You are viewing a single comment

It sources (includes) any file found in ~/.bashrc.d/ so check that directory.

but there is no such directory

Then it should have no effect.

This is just a nice way to define file-discrete .rc scripts. Like, maybe you have one for shell stuff, one for your custom collection of command aliases, one for initializing pyenv+pyenv-virtualenv, etc. That way, you have domain-constrained .rcs, and it’s easier to scan through things to see if something funny is going on / is broken or whatever.

It just checks to see if there is anything in a bash.d folder, if there isn't it moves on. Just somebody being preemptively helpful to check for other locations