hadoop fs -ls globbing gives inconsistent exit code ---------------------------------------------------
Key: HDFS-2685 URL: https://issues.apache.org/jira/browse/HDFS-2685 Project: Hadoop HDFS Issue Type: Bug Affects Versions: 0.20.205.0, 0.20.204.0, 0.20.2 Reporter: Mitesh Singh Jat _hadoop fs -ls_ command gives exit code for globbed input path, which is the exit code for the last resolved absolute path. Whereas _ls_ command always give same exit code regardless of position of non-existent path in globbing. {code:bash}$ hadoop fs -mkdir input/20110{1,2,3}/{A,B,C,D}/{1,2} {code} Since directory 'input/201104/' is not present, the following command gives 255 as exit code. {code:bash}$ hadoop fs -ls input/20110{1,2,3,4}/ ; echo $? {code} {noformat} Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/D Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/D Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/D ls: Cannot access input/201104/: No such file or directory. {noformat} {color:red}255{color} The directory 'input/201104/' is not present but given as second last parameter in globbing. The following command gives 0 as exit code, because directory 'input/201103/' is present. {code:bash}$ hadoop fs -ls input/20110{1,2,4,3}/ ; echo $? {code} {noformat} Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201101/D Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201102/D ls: Cannot access input/201104/: No such file or directory. Found 4 items drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/A drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/B drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/C drwxr-xr-x - mitesh supergroup 0 2011-12-15 11:51 /user/mitesh/input/201103/D {noformat} {color:green}0{color} Whereas, on Linux, ls command gives non-zero(2) as exit code, irrespective of position of non-existent path in globbing. {code:bash}$ mkdir -p input/20110{1,2,3,4}/{A,B,C,D}/{1,2} {code} {code:bash}$ ls input/20110{1,2,4,3}/ ; echo $? {code} {noformat} /bin/ls: input/201104/: No such file or directory input/201101/: ./ ../ A/ B/ C/ D/ input/201102/: ./ ../ A/ B/ C/ D/ input/201103/: ./ ../ A/ B/ C/ D/ {noformat} {color:red}2{color} {code:bash}$ ls input/20110{1,2,3,4}/ ; echo $? {code} {noformat} /bin/ls: input/201104/: No such file or directory input/201101/: ./ ../ A/ B/ C/ D/ input/201102/: ./ ../ A/ B/ C/ D/ input/201103/: ./ ../ A/ B/ C/ D/ {noformat} {color:red}2{color} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira