Skip to content
Snippets Groups Projects

`command -v` portability

Merged Eli Schwartz requested to merge eschwartz/xdg-utils:command-v-portability into master
Compare changes
  • Side-by-side
  • Inline
Files
1
  • Instead of using the 'which' program to resolve a command to an on-disk
    executable filename, use the 'env' program to run it. The former is
    non-portable and may not be installed on all systems, while the latter
    is guaranteed to be anywhere.
    
    I believe the intention of this code was to ensure that when running
    completely arbitrary third-party Exec= specifications, we do not
    accidentally end up running a conflicting shell function definition.
    Using 'env' fulfills this goal by entering a new environment context
    with an unmodified environment (we do not make use of env's stated
    purpose of creating a modified enviroment context) and then invoking the
    command using exec(3) rather than a shell.
Loading