#4 Sysfiles

Open
opened 4 years ago by karasz · 4 comments
karasz commented 4 years ago
Owner

At the moment the /etc/profile we install with sysfiles tries to load in bash every file there is in /etc/profile.d. This code:

# include local profiles
#
for x in /etc/profile.d/* /etc/conf/profile ; do
	[ -f $x ] && . $x
done

At least gawk (probably others) install in /etc/profile non bash files (gawc.csh).

We need to expand the code in the sysfiles: /etc/profile to something along the lines of:

# include local profiles
#
for x in /etc/profile.d/* /etc/conf/profile ; do
	if [ -f $x ]; then
		case "$x"
			*.csh) continue ;;
			*) . $x ;;
		esac
	fi
done
At the moment the /etc/profile we install with sysfiles tries to load in bash every file there is in /etc/profile.d. This code: ```bash # include local profiles # for x in /etc/profile.d/* /etc/conf/profile ; do [ -f $x ] && . $x done ``` At least gawk (probably others) install in /etc/profile non bash files (gawc.csh). We need to expand the code in the sysfiles: /etc/profile to something along the lines of: ```bash # include local profiles # for x in /etc/profile.d/* /etc/conf/profile ; do if [ -f $x ]; then case "$x" *.csh) continue ;; *) . $x ;; esac fi done ```
karasz self-assigned this 4 years ago
Owner

In this case I'm more of a fan of something like:

for x; do
	# skip empty and .csh files
	[ -s "$x" -a "$x" = "${x%.csh}" ] || continue

	. "$x"
done
In this case I'm more of a fan of something like: ```sh for x; do # skip empty and .csh files [ -s "$x" -a "$x" = "${x%.csh}" ] || continue . "$x" done ```
Poster
Owner

I thought we agreed that in order to be able to expand the exclusion list in a cleaner way we will use a case statement...

I thought we agreed that in order to be able to expand the exclusion list in a cleaner way we will use a case statement...
Owner

I thought we agreed that in order to be able to expand the exclusion list in a cleaner way we will use a case statement...

I was simply documenting the approach I would prefer, not that I was against of using a case

> I thought we agreed that in order to be able to expand the exclusion list in a cleaner way we will use a case statement... I was simply documenting the approach I would prefer, not that I was against of using a `case`
karasz added a new dependency 4 years ago
Poster
Owner

It is interesting to know that for example Ubuntu has the relevand code snippet:

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

The issues is that we have packages that install files in /etc/profile.d/ without extension (I am looking at you pkgconfig and Python). Usually those are files with only one export statement or so.

I think that we should use something that only sources files that either have no extension or have a .sh extension. I would not filter files with .csh extension because what if tomorrow something installs a .tsh or who knows what.

Maybe something on the lines of:

if [ -d /etc/profile.d ]; then
  for i in $(find /etc/profile.d/ -type f ! -name "?*.*" -o -name "*.sh"); do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

It is interesting to know that for example Ubuntu has the relevand code snippet: ```bash if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset i fi ``` The issues is that we have packages that install files in `/etc/profile.d/` without extension (I am looking at you `pkgconfig` and `Python`). Usually those are files with only one `export` statement or so. I think that we should use something that only sources files that either have no extension or have a `.sh` extension. I would not filter files with `.csh` extension because what if tomorrow something installs a `.tsh` or who knows what. Maybe something on the lines of: ```bash if [ -d /etc/profile.d ]; then for i in $(find /etc/profile.d/ -type f ! -name "?*.*" -o -name "*.sh"); do if [ -r $i ]; then . $i fi done unset i fi ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Blocks
#6 gawk
OpenSDE/package-nopast
Loading…
There is no content yet.