D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] shell script



paul wrote:

I saved my homedirectory /home/pausut path in a file called pwd1, then using
cd < pwd1 I changed it back to my home directory from the doomlegacy
directory. otherwise the script would leave me in the doomlegacy directory.

Yes but the file pwd1 is in the wrong directory.

The reason it works is that the shell you are in doesn't change
it's current directory.

When you run the script it forks another shell, which changes
directory, runs the program, fails to change back and then
exits.

Try a script like;

#!/bin/bash
cd /tmp

To get the idea.

To run a program in the current shell you use "." thus if we
call the above "cdtmp" compare

./cdtmp
. ./cdtmp

----- Original Message -----
From: "Simon Waters" <Simon@xxxxxxxxxxxxxxxxxxxx>
To: <list@xxxxxxxxxxxx>
Sent: Wednesday, June 19, 2002 10:13 AM
Subject: Re: [LUG] shell script

#/bin/bash

if [ "$DISPLAY" ]; then
 pwd > pwd1
 cd /opt/legacy-1.32beta4
 ./llxdoom
 echo exiting game
 cd < pwd1

What pwd1 file would that be ;)

Does "cd $OLDPWD" work in scripts I wonder.

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.

-- 
"Don't get me started on intuitive. You know what's intuitive?
Fear of heights. Everything else we call intuitive, such as
walking or using a pencil took years of practice." - Don Norman

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly