tadfisher / pass-otp

A pass extension for managing one-time-password (OTP) tokens
GNU General Public License v3.0
1.28k stars 85 forks source link

Use command instead of which #116

Closed roddhjav closed 3 years ago

roddhjav commented 4 years ago

Hi @tadfisher

This PR replaces the use of which by the builtin shell command. That allow to not require which as an extra dependency.

See #115

baierjan commented 4 years ago

Unfortunately, command -v is not a replacement for which. Please note the differences for shell builtins and aliases:

$ alias ls='ls --color=auto'
$ which ls
/usr/bin/ls
$ command -v ls
alias ls='ls --color=auto'
tadfisher commented 3 years ago

A better option is to convert otp.bash to a template and make these paths configurable via the makefile. Going to close and open an issue for this.

ayushnix commented 2 years ago

Unfortunately, command -v is not a replacement for which. Please note the differences for shell builtins and aliases:

Just wanted to let people know that bash aliases are not used by default when using command -v inside scripts

Here's a simple snippet to confirm this on your system assuming ls is an alias

#!/bin/bash

command -v ls

This should still output something like /usr/sbin/ls and not the alias. I've closed https://github.com/tadfisher/pass-otp/pull/159 but I don't see how using command -v could cause issues.