a-dma/yubitouch

Avoid errors when commands don't exist

gatheall opened this issue · 5 comments

I discovered your script today and successfully used it to require touch for my Yubikeys. Thanks!

One minor issue I saw when running it was a message from which telling me that I don't have xxd on my system; eg,

which: no xxd in (/usr/sbin:/usr/bin:/sbin:/bin)

Is it worth redirecting stderr to /dev/null each time calling that in the script?

a-dma commented

Hey, I'm glad that you found this useful.

Interesting problem there, my which is nice and quiet and doesn't seem to complain. What OS and shell are you running? BSD?

Using which is generally not the best choice, but for a different set of reasons. Does replacing that with command -v make it better for you? If so I may update the script.

Interesting problem there, my which is nice and quiet and doesn't seem to complain. What OS and shell are you running? BSD?

This happens on Gentoo. bash is 5.0.16(1)-release, and the which implementation is from https://carlowood.github.io/which/

Using which is generally not the best choice, but for a different set of reasons. Does replacing that with command -v make it better for you? If so I may update the script.

That works for me; eg,

theall@garlic:~>which xxd
which: no xxd in (/usr/sbin:/usr/bin:/sbin:/bin)
theall@garlic:~>command -v xxd

and

theall@garlic:~>which od
/usr/bin/od
theall@garlic:~>command -v od
/usr/bin/od
a-dma commented

I see. I'm also using Bash I'm a few minors away. It must be the implementation of which.

I've been meaning to do away with that anyway, but never gotten around to. I'll push a small diff. Feedback would be appreciated if you have the time.

Thanks.

I see. I'm also using Bash I'm a few minors away. It must be the implementation of which.

I've been meaning to do away with that anyway, but never gotten around to. I'll push a small diff. Feedback would be appreciated if you have the time.

Thanks, the patch fixed the issue I had and looks good to me. [For what it's worth, though, PE is still defined using which.]

a-dma commented

Derp.

Thanks and thanks for testing.