Bug 1149882 - /etc/profile fails to load if the user is using Fish as their shell
/etc/profile fails to load if the user is using Fish as their shell
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: Simon Lees
E-mail List
Depends on:
  Show dependency treegraph
Reported: 2019-09-08 02:57 UTC by Doug Beney
Modified: 2019-09-12 07:21 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Doug Beney 2019-09-08 02:57:44 UTC
For any user that has fish set as their default shell, /etc/profile is sourced using fish shell and /etc/profile is not compatible with fish.

To create a reproducible error:
- Open fish shell (it does not to be your default shell for this test)
- Run the command "source /etc/profile"

You will get this error:

/etc/profile (line 15): 'case' builtin not inside of switch block
    case "$0" in
from sourcing file /etc/profile
        called on standard input

source: Error while reading file “/etc/profile”

Here is my full /etc/profile: https://hastebin.com/buyeruwoza.bash

Comment 1 Alynx Zhou 2019-09-09 03:44:12 UTC
I am afraid that this is not a bug, you know fish has a different syntax from bash, and by default /etc/profile is written in bash syntax. It seems people suggests to use fish as interactive shell started by bash instead of as default shell, so you can load files with bash. Or you should rewrite /etc/profile in fish syntax by yourself because most people use bash as default shell and many shells use bash syntax.
Comment 2 Simon Lees 2019-09-12 07:21:31 UTC
@Alynx is partly correct, fish uses its own syntax which isn't posix compatible this means it can't source `/etc/profile` by design. Instead it ships its own config files in different locations, the equivalent to `/etc/profile` for configuration that affects all users on the system is `/etc/fish/config.fish` any changes you would normally make to `/etc/profile` should also be done there using fish syntax so that fish users pick them up.

Fish however does work fine on openSUSE as a users default shell, I have been using it as mine for a number of years, I have an extensive config at https://github.com/simotek/tackle 

However it should be noted that currently openSUSE doesn't ship anything in `/usr/share/fish/vendor_cpnf.d` to replace the content of the standard `/etc/profile` so if you find anything that doesn't work in fish because its missing raise a bug and i'll include it. I suspect gcc is broken because of this so I plan to fix that and go through and look for other possible issues when I have time, but if you know of issues let me know and i'll make sure they are fixed as well.