hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Isaacson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-8386) hadoop script doesn't work if 'cd' prints to stdout (default behavior in Ubuntu)
Date Fri, 28 Sep 2012 22:31:07 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-8386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13465962#comment-13465962
] 

Andy Isaacson commented on HADOOP-8386:
---------------------------------------

The Gnu Autoconf manual has this to say:
http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Special-Shell-Variables.html
{quote}
CDPATH
    When this variable is set it specifies a list of directories to search when invoking cd
with a relative file name that did not start with ‘./’ or ‘../’. Posix 1003.1-2001
says that if a nonempty directory name from CDPATH is used successfully, cd prints the resulting
absolute file name. Unfortunately this output can break idioms like ‘abs=`cd src &&
pwd`’ because abs receives the name twice. Also, many shells do not conform to this part
of Posix; for example, zsh prints the result only if a directory name other than . was chosen
from CDPATH.

    In practice the shells that have this problem also support unset, so you can work around
the problem as follows:

              (unset CDPATH) >/dev/null 2>&1 && unset CDPATH

    You can also avoid output by ensuring that your directory name is absolute or anchored
at ‘./’, as in ‘abs=`cd ./src && pwd`’. 
{quote}
So the Bash behavior is specified by Posix, alas. It is specified to write to stdout not stderr,
so the patch is correct in that regard (I was concerned we might also need {{2>&1}}
or similar).

So, LGTM.  I'll upload a patch that conforms to test-patch expectations. Thanks for the contribution,
Christopher!
                
> hadoop script doesn't work if 'cd' prints to stdout (default behavior in Ubuntu)
> --------------------------------------------------------------------------------
>
>                 Key: HADOOP-8386
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8386
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: scripts
>    Affects Versions: 1.0.2
>         Environment: Ubuntu
>            Reporter: Christopher Berner
>         Attachments: hadoop.diff
>
>
> if the 'hadoop' script is run as 'bin/hadoop' on a distro where the 'cd' command prints
to stdout, the script will fail due to this line: 'bin=`cd "$bin"; pwd`'
> Workaround: execute from the bin/ directory as './hadoop'
> Fix: change that line to 'bin=`cd "$bin" > /dev/null; pwd`'

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message