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 -v instead of which to prevent errors on stderr #123

Open eklitzke opened 3 years ago

eklitzke commented 3 years ago

I upgraded to a more recent version of otp.bash and now I'm getting an error message like this preceding my otp output:

which: no otptool in (/home/evan/.local/bin:/home/evan/go/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)

This fixes the issue by using command -v instead of which; it's also possible to fix this by redirecting which stderr to /dev/null, but using command instead of which is better anyway because command is a bash builtin.

roddhjav commented 3 years ago

Duplicate of #116

methadata commented 3 years ago

Thank you for pointing to the #116

The underlying issue is that script fails if otptool is not found in the system. In my case, I have been unable to install it in RHEL8, and found nothing googling about it.

Is there any way to make otptool available so the otp.bash script doesn't fail in the which statement? Is there any other option, taking into account that the script seems to work without it?

zneix commented 2 years ago

@tadfisher as I can tell by https://github.com/tadfisher/pass-otp/pull/116#issuecomment-691537592 I see you're against using command -v over which, but would you accept a change which would at least suppress all the error messages caused by which? These are really annoying and while I still think command -v is 100% the way to go (even upstream pass relies on it and uses it), I'd want to have any sort of half-solution to this problem.