[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: CDPATH and shell scripts



[...]
> So what is the right course of action here?
> 
> 1) unset CDPATH in every single shell script there is?
> 2) never use relartive paths for cd in scripts?
> 3) shoot the user for doing something dumb?
> 4) disable CDPATH in /bin/sh (or is that POSIX?) or non-interactive
>    scripts (would break automake I think)
> 

Looking at some autoconf-generated configure script I've found the following:

--------------------------------------------------------------------------------
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
--------------------------------------------------------------------------------

I had once stumbled over this problem and ever since I keep using

cd bla > /dev/null

whenever the output could possibly trouble me. But well, actually, unsetting
CDPATH would be more appropriate.

Best,
Michael

Attachment: pgpqvCVfameJj.pgp
Description: PGP signature


Reply to: