You are not logged in.
Yesterday all of a sudden stuff in .profile stopped working the way it should. I have modified PATH set there, and normally I'd write it as "export PATH=$PATH:~/scripts". But since yesterday that no longer works, my PATH just literally says "~/scripts" instead of "/home/gokop/scripts" and content of this folder is not accessible. I had to replace ~ with /home/gokop and only then it worked. What's interesting, when I sourced .profile in open terminal, it was interpreted properly, translating ~ to /home/gokop.
I synchronize my dotfiles between computers to easily keep the same configuration and tweaks I make from time to time. For that reason, in .profile I source another file (.profile is synchronized, the other file isn't). That file exports a variable. Normally it would work with no problem, but since yesterday the variable isn't being declared unless I put it directly in .profile. This problem also doesn't exist when I source .profile in shell.
Any idea what's happening? I could "solve" this by sourcing .profile in tty and then doing startx but I'm more comfortable using a login manager. Oh and also, is it normal that .profile has no effect on login in ttys? Cause I'm not sure
Last edited by GOKOP (2019-05-18 13:05:19)
Offline
Sounds related to the actual shell interpreter (probably not bash in the disfunctional case?)
Online
I use zsh, but I changed my shell to bash and problem still occurs.
Offline
Not your interactive shell but whatever is running that is not
I could "solve" this by sourcing .profile in tty and then doing startx but I'm more comfortable using a login manager.
Some DM maybe?
Online
Okay whatever, I'm just stupid. So yesterday I changed my /bin/sh to point to dash and I didn't quite connect the facts. So dash is just too minimal for stuff like sourcing etc. Problem is solved
Offline
Ah, no, clearly dash did source the file, it just does not do tilde-expansion as that is a feature specific to BASH (and a couple other feature-filled shells). Oddly, even the bash manual specifies it may only expand unquoted tildes.
$HOME however is defined in all POSIX shells including dash. Use that and do it right:
export PATH="$PATH:$HOME/scripts"Last edited by Trilby (2019-05-18 14:14:17)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
.profile should always be POSIX compliant, bash-specific syntax belongs in .bash_profile or .bashrc.
You might find checkbashisms useful.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline
Ah, no, clearly dash did source the file, it just does not do tilde-expansion as that is a feature specific to BASH (and a couple other feature-filled shells). Oddly, even the bash manual specifies it may only expand unquoted tildes.
$HOME however is defined in all POSIX shells including dash. Use that and do it right:
export PATH="$PATH:$HOME/scripts"
When I wrote about sourcing I didn't mean PATH but the other file I was writting about. I checked and "source" command is indeed not in dash.
Offline
Ah, yes, the `source` command is not POSIX, but is also a BASH feature. But sourcing other files is not limited to BASH - again, just do it right with the `.` command.
You are trying to use dash and .profile, but you are expecting them to work like bash and .bash_profile. When they don't work the way you expected, it doesn't mean they can't work, you just need to stop using bashisms in non-bash environments.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline