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

  • TootSweet@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    If you’re thinking it may be malicious, I think it’s innocuous.

    Try cat’ing /etc/skel/.bashrc and see if the code in question in in there. My guess is it will be. When a new user’s home directory is created, it copies all the files from /etc/skel into the newly-created home directory. So, that directory is basically a “new user home directory template.”

    The code you posted (is missing an fi at the end, but anyway) just looks like a utility for making it easier to organize your .bashrc into separate files rather than one big file. That’s a common technique for various configuration files that a lot of distros commonly do. And I personally find that technique nice.

    If you want to delete that code, it’s not going to hurt anything to remove it (unless someday you add a ~/.bashrc.d/ directory and some file in there “doesn’t work” and it confuses you why.)

    Also, what distro are you on?