Вопрос

I am not a Solaris expert and I am trying to create a shell script that will change my prompt to PWD and the ksh to bash and I have this:

PS1='$PWD $ ' exec bash --noprofile --rcfile /dev/null

or

PS1='\w $' exec bash --noprofile --rcfile /dev/null

Both of them dont work from a sh. if i add them from the command line then the first time my bash appears on prompt and the second time the PS1='$PWD $' kicks in and my prompt changes.

Firstly, why is PS1='$PWD $' not working from shell script . and why do i have to run the command from command line twice to acheive my results.

Also, in my export/home/syed/ directory there are three files local.login, local.profile, and local.cshrc. is there any way i can use them that when ever i log in i dont need to run my shell script and upon login i get bash shell and my prompt as i want it (am i asking too much, i dont like the ksh as it does not have any features like up arrow recall last commands and tab auto complete features)

thanks Syed...

Это было полезно?

Решение

When you exec from within a script, the script is what is replaced, not the parent shell.

Try sourcing the script rather than running it.

Also, in Solaris, you can use passwd -e to change your login shell.

You may be able to symlink ~/.profile to your existing ~/local.profile (or similar). Note that .cshrc is for the C Shell and is not compatible with ksh or Bash.

Другие советы

If you want that your default shell will be bash, change it in /etc/passwd

When you exec bash it sets up its own environment from scratch. Pass it an --rcfile containing the settings you would like for it to inherit.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top