Re: [Rd] (PR#8363) R CMD INSTALL fails if cd prints stuff to stdout

From: <ripley_at_stats.ox.ac.uk>
Date: Fri 02 Dec 2005 - 17:20:33 GMT


What shells are these? You don't give an example that causes trouble, and in particular no way to reproduce this.

The behaviour you describe is prohibited by the POSIX standard, so the problem would appear to be with the unnamed shell. I can see how it could happen if a user redefines 'cd', but then a user could redefine all the commands in his OS and we have to make some reasonable assumptions

You seem not to have submitted a patch against the R sources, which contain src/scripts/INSTALL.in, not INSTALL, and it contains changes you do not mention.

On Fri, 2 Dec 2005 p.lijnzaad@med.uu.nl wrote:

>
> --Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)
> Content-type: text/plain; charset="us-ascii"
> Content-disposition: inline
> Content-transfer-encoding: 7bit
>
> Dear all,
>
> I came across puzzling behaviour of R CMD INSTALL, which I tracked down to the
> fact that in some shells (or in some user customizations of them), the cd
> command prints out the new directory. As a result, the $pkgs variable gets a
> wrong value, e.g.in the following transcript:
>
> philip@gen031:tmp$ R CMD INSTALL GlobalAncova
> /usr/lib/R/bin/INSTALL: line 873: cd: /home/philip/tmp/GlobalAncova
> /var/tmp/philip/misc/GlobalAncova: No such file or directory
> sed: can't read DESCRIPTION: No such file or directory
> ERROR: no 'Package' field in 'DESCRIPTION'
> philip@gen031:tmp$
>
> The error at line 873 is due to the variable $pkgs containing the string
> '/home/philip/tmp/GlobalAncova
> /var/tmp/philip/misc/GlobalAncova'
>
> (i.e. including the new line. Incidentally, /home/philip/tmp dir is a symlink
> to /var/tmp/philip/misc; hence the non-identical directory names).
>
> A simple fix (cd "${1}" > /dev/null 2>&1 && ${GETWD}) takes care of this, and
> should work under sh, ksh, bourne shell, zsh. A context diff is attached; I
> hope this will prove useful. Kind regards,
>
>
> Philip
>
> --
> Philip Lijnzaad
> Genomics Laboratory
> Dept. of Biomedical Genetics
> University Medical Center (UMC), Utrecht
> Stratenum room 2.201 (on Mondays and Thursdays not in after 14.45)
> MSN chat (*NOT* email): philip_lijnzaad@hotmail.com
> P.O. Box 85060, 3508 AB Utrecht
> (Universiteitsweg 100, 3584 CG Utrecht)
> The Netherlands
> tel: +31 (0)30 253 8464
> fax: +31 (0)30 253 8479
>
> --Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)
> Content-type: text/x-diff; charset="us-ascii"; name="INSTALL.patch"
> Content-disposition: attachment; filename="INSTALL.patch"
> Content-transfer-encoding: 7bit
>
> *** INSTALL~ Wed Jun 22 11:09:59 2005
> --- INSTALL Fri Dec 2 17:08:50 2005
> ***************
> *** 127,136 ****
> get_packages () {
> ## get the full path names to all packages contained in $1.
> ## NOTE: modifies pkgs!
> if grep "^Contains:" "${1}/DESCRIPTION" >/dev/null; then
> bundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`
> for p in ${bundlepkg}; do
> ! pkgs="${pkgs} \"`cd "${1}/${p}" && ${GETWD}`\""
> if test -f "${1}/${p}/DESCRIPTION.in"; then
> ## Try being defensive about missing final newlines, or extra
> ## empty lines.
> --- 127,138 ----
> get_packages () {
> ## get the full path names to all packages contained in $1.
> ## NOTE: modifies pkgs!
> + PROMPT_COMMAND=
> + BASH_COMMAND=
> if grep "^Contains:" "${1}/DESCRIPTION" >/dev/null; then
> bundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`
> for p in ${bundlepkg}; do
> ! pkgs="${pkgs} \"`cd "${1}/${p}>/dev/null 2>&1" && ${GETWD}`\""
> if test -f "${1}/${p}/DESCRIPTION.in"; then
> ## Try being defensive about missing final newlines, or extra
> ## empty lines.
> ***************
> *** 139,145 ****
> fi
> done
> else
> ! pkgs="${pkgs} \"`cd "${1}" && ${GETWD}`\""
> fi
> }
>
> --- 141,147 ----
> fi
> done
> else
> ! pkgs="${pkgs} \"`cd "${1}" > /dev/null 2>&1 && ${GETWD}`\""
> fi
> }
>
>
> --Boundary_(ID_erFAa+o6kWefQxXf6GD2RA)--
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Dec 03 10:32:33 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT