Hi Eli,

On 05/02/18 19:25, Eli Schwartz wrote:
> Package: xvfb
> Version: 2:1.19.6-1
> Severity: minor
> 
> Arch Linux has imported the xvfb-run script from Debian's package, but
> our package dependencies do not mandate that the "which" utility be
> installed. OTOH we do have it in our base package group, which users are
> expected to have installed, although there is a bit of bikeshedding
> about whether these unstated dependencies should actually be explicitly
> listed... See the following xvfb bugreport on our bugtracker:
> https://bugs.archlinux.org/task/56997
> 
> All that being said, this immediately made me think, why is the script
> using `which` at all, rather than the POSIX `command -v` which is far
> more portable as any #!/bin/sh shell has this as a builtin. It also
> provides a micro-optimization by avoiding an external subprocess.
> 
> Please consider making this script more reusable by switching to the
> POSIX shell builtin.
> 
> Example output on a system which does not have /usr/bin/which available:
> 
> $ xvfb-run some_command
> /usr/bin/xvfb-run: line 139: which: command not found
> xvfb-run: error: xauth command not found
> 
> (This error message seems rather redundant.)

There are some differences in command vs which, e.g.:

emilio@tatooine:~$ which ls
/bin/ls
emilio@tatooine:~$ command -v ls
alias ls='ls --color=auto'

Some special casing would need to be added to handle aliases, whereas with
'which' we don't.

OTOH portability is a good goal and I'm happy that you're using xvfb-run, so if
we can come up with a good and clean solution then that'd be good.

Cheers,
Emilio

Reply via email to