From efe41e732a29e21bfe88c791c221d5c38e827f1e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 28 Oct 2013 16:08:16 -0700 Subject: [PATCH] gnulib-tool: protect against CDPATH * gnulib-tool: Some "cd" built-in functions print a directory name to stdout when CDPATH is set, e.g., $ bash -c 'CDPATH=/; cd tmp' /tmp Unset that envvar, when possible. Prompted by a comment from Bruce Korb. --- ChangeLog | 8 ++++++++ gnulib-tool | 3 +++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6fca0c7..b64d8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2013-10-28 Jim Meyering + gnulib-tool: protect against CDPATH + * gnulib-tool: Some "cd" built-in functions print a directory name + to stdout when CDPATH is set, e.g., + $ bash -c 'CDPATH=/; cd tmp' + /tmp + Unset that envvar, when possible. + Prompted by a comment from Bruce Korb. + maint.mk: restore functionality removed by recent change... Sunday's change, v0.0-8062-g6b24f60, may have appeared correct from the context of a shallow-cloned gnulib repository: "git describe" diff --git a/gnulib-tool b/gnulib-tool index ed693e0..152de86 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -898,6 +898,9 @@ if test "X$1" = "X--no-reexec"; then shift fi +# Unset CDPATH. Otherwise, output from the 'cd dir' can surprise callers. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + # Command-line option processing. # Removes the OPTIONS from the arguments. Sets the variables: # - mode one of: list, find, import, add-import, remove-import, -- 1.8.4.1.559.gdb9bdfb