mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	whence -a: fix spurious 'undefined function' message
$ ksh -c 'whence -a printf' printf is a shell builtin printf is /usr/bin/printf printf is an undefined function The third line should not appear. src/cmd/ksh93/bltins/whence.c: - Remove faulty extra check for undefined (= autoload) functions. This was already handled earlier, on lines 192-193. src/cmd/ksh93/tests/builtins.sh: - Add regression test. - For previous 'whence -a' test, don't bother with shell function. Fixes https://github.com/ksh93/ksh/issues/26
This commit is contained in:
		
							parent
							
								
									b2bdbef561
								
							
						
					
					
						commit
						01c25cb14b
					
				
					 2 changed files with 13 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -732,20 +732,27 @@ foo=BUG command eval ':'
 | 
			
		|||
[[ $foo == BUG ]] && err_exit '`command` fails to disable the special properties of special builtins'
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
# `whence -a` should not base the path of tracked aliases on the current directory
 | 
			
		||||
run_whence()
 | 
			
		||||
{
 | 
			
		||||
	whence -a chmod >> /dev/null
 | 
			
		||||
# 'whence -a' tests
 | 
			
		||||
 | 
			
		||||
# wrong path to tracked aliases after loading builtin: https://github.com/ksh93/ksh/pull/25
 | 
			
		||||
actual=$("$SHELL" -c '
 | 
			
		||||
	whence chmod >/dev/null  # add to hash table (create tracked alias)
 | 
			
		||||
	builtin chmod
 | 
			
		||||
	whence -a chmod
 | 
			
		||||
}
 | 
			
		||||
actual="$(run_whence)"
 | 
			
		||||
')
 | 
			
		||||
expected="chmod is a shell builtin
 | 
			
		||||
$(whence -a -p chmod | sed 's/^/chmod is /')
 | 
			
		||||
chmod is a tracked alias for $(whence -p chmod)"
 | 
			
		||||
[[ $actual == $expected ]] || err_exit "'whence -a' does not work correctly with tracked aliases" \
 | 
			
		||||
	"(expected $(printf %q "$expected"), got $(printf %q "$actual"))"
 | 
			
		||||
 | 
			
		||||
# spurious 'undefined function' message: https://github.com/ksh93/ksh/issues/26
 | 
			
		||||
actual=$("$SHELL" -c 'whence -a printf')
 | 
			
		||||
expected="printf is a shell builtin
 | 
			
		||||
$(whence -a -p printf | sed 's/^/printf is /')"
 | 
			
		||||
[[ $actual == $expected ]] || err_exit "'whence -a': incorrect output" \
 | 
			
		||||
	"(expected $(printf %q "$expected"), got $(printf %q "$actual"))"
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
# 'cd ../.foo' should not exclude the '.' in '.foo'
 | 
			
		||||
(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue