Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/hairyhenderson/go-which
A cross-platform Go implementation of the which(1)
command, usable both as a CLI and library.
Usage of which:
-a List all instances of executables found (instead of just the first).
-s No output, just return 0 if all executables are found, or 1 if some were not found.
-v Print the version
Unlike the UNIX which(1)
command, even if multiple programs are given as input, only the first one found will be returned.
Chances are you don't really need this, since most UNIX-like OSes come with the more established (and significantly smaller) C implementation of which(1)
, either as a standalone binary, or as a shell builtin.
But if there's some reason this may be useful to you, you can use this just like the normal which(1)
:
$ which zsh
/usr/local/bin/zsh
$ which -a zsh
/usr/local/bin/zsh
/bin/zsh
$ which zsh bash sh
/usr/local/bin/zsh
$ which -a zsh bash sh
/usr/local/bin/zsh
/bin/zsh
/bin/bash
/bin/sh
$ if (which -s zsh bash); then
> echo 'I have zsh and bash installed';
> fi
I have zsh and bash installed
$ if (which -s zsh bash ash); then echo 'yup'
> else
> echo "I'm missing one of them...";
> fi
I'm missing one of them...
If you're writing a program in the Go language, it can be useful to not have to shell out to which(1)
to locate a binary.
The simplest usage is:
package main
import (
"fmt"
"github.com/hairyhenderson/go-which"
)
func main() {
zshPath := which.Which("zsh")
fmt.Printf("zsh found at %s", zshPath)
}
See the godocs for more information.
Copyright (c) 2018-2020 Dave Henderson
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.