Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Problem with /bin/sh profile

Altera_Forum
Honored Contributor II
1,719 Views

Another problem that has been puzzling me lately. I'm running the /bin/sh shell and I can't seem to pick up changes in the /etc/profile file. For referrence, here's the file I'm using (copied from another machine): 

 

-------------------------------------------------------------------------------------# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). 

 

PATH="/usr/local/bin:/usr/bin:/bin" 

 

if [ "$PS1" ]; then 

if [ "$BASH" ]; then 

PS1='\u@\h:\w\$ ' 

else 

if [ "`id -u`" -eq 0 ]; then 

PS1='whoami# ' 

else 

PS1='whoami$ ' 

fi 

fi 

fi 

 

export PATH 

------------------------------------------------------------------------------------- 

 

From what I can tell from messing around with /bin/sh, it doesn't appear to be reading the /etc/profile file. Is this something to do with uKit's uClinux port or something I'm missing?  

 

Ultimately, I'd just like to display the path in the prompt, but right now I'd settle for whoami. 

 

Thanks.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
724 Views

I'll poke around sometime today or tommorow and see if I can find out why it's give you problems.

0 Kudos
Altera_Forum
Honored Contributor II
724 Views

Thanks, although I might have figured it out. 

 

It turns out I'm starting /bin/sh from the login program and not from inittab. So I had to change the login program to pass a '-' character otherwise /bin/sh won't read from /etc/profile.  

 

execl("/bin/sh", "/bin/sh", 0); 

 

Became 

 

execl("/bin/sh", "-/bin/sh", 0); 

 

Now I'm picking up settings in /etc/profile, but it doesn't appear that /bin/sh can handle variables. I've tried $PWD and \w to get a path into the prompt, but neither have worked.  

 

Oh well.
0 Kudos
Reply