|
From: | Jan Schampera |
Subject: | Weird behaviour of 'hash' builtin |
Date: | Sun, 30 May 2010 10:22:09 +0200 |
User-agent: | Mozilla-Thunderbird 2.0.0.24 (X11/20100329) |
Hello Chet, hello list,during some discussion in the IRC #bash channel on freenode we found a weird behaviour of the 'hash' builtin command.
The command exits true if the operand in question contains a /, no matter if that makes sense or not:
---$ hash 'CHANGELOG_CURRENT="http://slackware.osuosl.org/slackware-current/ChangeLog.txt"'; echo $?
0 --- --- $ hash 'meow/foo/baz'; echo $? 0 ---This alone is weird enough. When you add the -t option (if available) to print the pathname, it fails:
---$ hash -t 'CHANGELOG_CURRENT="http://slackware.osuosl.org/slackware-current/ChangeLog.txt"'; echo $? bash: hash: CHANGELOG_CURRENT="http://slackware.osuosl.org/slackware-current/ChangeLog.txt": not found
1 --- --- $ hash -t 'meow/foo/baz'; echo $? bash: hash: meow/foo/baz: not found 1 ---This happens on a 2.04 (no -t option to check the other case) aswell as on a 4.1.
If this is not a bug, what's the reason behind this? Is it to blindly report success when an operand "looks like a pathname"?
Regards, Jan "TheBonsai"
[Prev in Thread] | Current Thread | [Next in Thread] |