Bug#4363: `which' cannot cope if command names contain spaces
Package: debianutils
Version: 1.2-3
-chiark:d> cat >'cmd with spaces'
#!/bin/sh
echo "called cmd with spaces: $@"
-chiark:d> chmod +x './cmd with spaces'
-chiark:d> './cmd with spaces' hi
called cmd with spaces: hi
-chiark:d> PATH=:$PATH 'cmd with spaces' hi
called cmd with spaces: hi
-chiark:d> PATH=:$PATH type -p 'cmd with spaces'
./cmd with spaces
-chiark:d> PATH=:$PATH which 'cmd with spaces'
-chiark:d> PATH=:$PATH which ls
/bin/ls
-chiark:d> ll
total 7
drwxrwsr-x 2 ian ian 1024 Sep 1 16:26 ./
drwxrwsr-x 23 ian ian 5120 Aug 31 19:52 ../
-rwxrwxr-x 1 ian ian 44 Sep 1 16:27 cmd with spaces*
-chiark:d> echo $SHELL
/bin/bash
-chiark:d>
This can be fixed by appropriate use of quoting, $@, and so on.
Ian.
Reply to: