Subject: cd success?
To: None <netbsd-users@netbsd.org>
From: Jan Danielsson <jan.m.danielsson@gmail.com>
List: netbsd-users
Date: 01/26/2007 08:58:35
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigAA9B38117677E44D02135049
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello all,
I have a script which contains the line:
rm -Rf *
As you might imagine, I'm somewhat afraid that script might run amok.
It shouldn't, obviously, but Just In Case... Is there any way to
determine if a "cd" was successful or unsuccessful?
The script does this:
cd ~/backup/foo
rm -Rf *
Currently, if the cd-command fails, I will have to kill myself. I
don't want to do that. If I remember correctly, there's a variable,
something like $? which gets set to the return code. Is that set for
internal shell commands as well?
Or should I use some:
if [ `pwd` =3D=3D "~/backup/foo" ] ; then
echo "Phew!...
fi
..instead?
--=20
Kind regards,
Jan Danielsson
--------------enigAA9B38117677E44D02135049
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)
iD8DBQFFubS0bgs4ia4rq9IRClHmAJ9EjIxoluKgCD5F5LXAAtAIoi1wbgCgmEwq
shjZp9oTRon9iIOIqDPMV7s=
=pYlq
-----END PGP SIGNATURE-----
--------------enigAA9B38117677E44D02135049--