'cd' in shell-script or .profile

Mike Moore mike at x.co.uk
Sat Jun 16 02:13:39 AEST 1990


In article <5672 at aplcen.apl.jhu.edu> trweil at aplcen.apl.jhu.edu (Weil Timothy Robert) writes:
>I'd like to be prompted after login as to which directory
>I'd like to be working in -
> 
>Tried a simple prompting via shell script; also tried
>inserting same prompting in .profile (Ultrix running
>Korn Shell)...
> 
>results were similar - a 'pwd' would indicate that I'd
>changed to the selected directory but UNIX kept me
>logged into $HOME....any other tricks to try?
> 

I don't know about korn shell, but Bourne shell works with:

c=`echo "\c"`; [ "$c" = "" ] && { c="\c"; n=""; } || { c=""; n="-n"; }
echo $n "Enter working directory: $c"
read HOME
export HOME
cd $HOME

if you put it into the .profile.  any cd after this will take you to
$HOME (i.e. your newly specified working directory)

don't worry about the first line, it just works out if you need \c or -n
to stop echo sending a newline to the terminal

Mike

-- 
--------------------------------------------------------------------------
Usual disclaimer.....  etc                        | mike at x.co.uk
True Intelligence is not knowing all the answers, |
it's knowing the right questions.                 |



More information about the Comp.unix.questions mailing list