You are not logged in.

#1 2019-05-18 12:06:11

GOKOP
Member
Registered: 2018-04-29
Posts: 51

[SOLVED] .profile misbehaving?

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

#2 2019-05-18 12:39:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,768

Re: [SOLVED] .profile misbehaving?

Sounds related to the actual shell interpreter (probably not bash in the disfunctional case?)

Offline

#3 2019-05-18 12:58:55

GOKOP
Member
Registered: 2018-04-29
Posts: 51

Re: [SOLVED] .profile misbehaving?

I use zsh, but I changed my shell to bash and problem still occurs.

Offline

#4 2019-05-18 13:00:48

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,768

Re: [SOLVED] .profile misbehaving?

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?

Offline

#5 2019-05-18 13:05:08

GOKOP
Member
Registered: 2018-04-29
Posts: 51

Re: [SOLVED] .profile misbehaving?

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

#6 2019-05-18 13:51:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] .profile misbehaving?

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

#7 2019-05-18 14:12:07

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] .profile misbehaving?

.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

#8 2019-05-18 20:35:46

GOKOP
Member
Registered: 2018-04-29
Posts: 51

Re: [SOLVED] .profile misbehaving?

Trilby wrote:

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

#9 2019-05-18 20:42:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] .profile misbehaving?

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

Board footer

Powered by FluxBB