[pacman-dev] [PATCH] scripts: unset CDPATH if cd is used
This wonderful/awful little bash shell variable wrecks havoc on `cd` calls in shell scripts. Unset CDPATH in makepkg where we use `cd` quite heavily. In pacman-optimize, we can move the change directory logic into the bsdtar call so we are left with no usages of `cd` in the script. Signed-off-by: Dan McGee <dan@archlinux.org> --- scripts/makepkg.sh.in | 2 ++ scripts/pacman-optimize.sh.in | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80bb1c9..5e8687e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -36,6 +36,8 @@ export TEXTDOMAINDIR='@localedir@' # file -i does not work on Mac OSX unless legacy mode is set export COMMAND_MODE='legacy' +# Ensure CDPATH doesn't screw with our cd calls +unset CDPATH myver='@PACKAGE_VERSION@' confdir='@sysconfdir@' diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 47d8814..8a4e722 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -122,8 +122,7 @@ find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old" # step 2: tar it up msg "$(gettext "Tar'ing up %s...")" "$dbroot" -cd "$dbroot" -bsdtar -czf "$workdir/pacman-db.tar.gz" ./ +bsdtar -czf "$workdir/pacman-db.tar.gz" -C "$dbroot" ./ if (( $? )); then rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" -- 1.7.9
On Tue, Feb 14, 2012 at 10:14:08AM -0600, Dan McGee wrote:
This wonderful/awful little bash shell variable wrecks havoc on `cd` calls in shell scripts. Unset CDPATH in makepkg where we use `cd` quite heavily. In pacman-optimize, we can move the change directory logic into the bsdtar call so we are left with no usages of `cd` in the script.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
ack. This should have been done forever ago, given how much makepkg changes directories.
scripts/makepkg.sh.in | 2 ++ scripts/pacman-optimize.sh.in | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80bb1c9..5e8687e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -36,6 +36,8 @@ export TEXTDOMAINDIR='@localedir@'
# file -i does not work on Mac OSX unless legacy mode is set export COMMAND_MODE='legacy' +# Ensure CDPATH doesn't screw with our cd calls +unset CDPATH
myver='@PACKAGE_VERSION@' confdir='@sysconfdir@' diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 47d8814..8a4e722 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -122,8 +122,7 @@ find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old"
# step 2: tar it up msg "$(gettext "Tar'ing up %s...")" "$dbroot" -cd "$dbroot" -bsdtar -czf "$workdir/pacman-db.tar.gz" ./ +bsdtar -czf "$workdir/pacman-db.tar.gz" -C "$dbroot" ./ if (( $? )); then rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" -- 1.7.9
participants (2)
-
Dan McGee
-
Dave Reisner