Created
January 5, 2023 02:22
-
-
Save meoow/3549fa5eaa91eacf0b027585107e5cab to your computer and use it in GitHub Desktop.
A wrap for voltiageshift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"os" | |
"path/filepath" | |
"syscall" | |
) | |
func main() { | |
flag.Parse() | |
ex, err := os.Executable() | |
if err != nil { | |
panic(err) | |
} | |
ex, err = filepath.EvalSymlinks(ex) | |
if err != nil { | |
panic(err) | |
} | |
selfdir := filepath.Dir(ex) | |
realrt := "voltageshift" | |
realfullrt := filepath.Join(selfdir, realrt) | |
if fi, ok := os.Stat(realfullrt); ok == nil { | |
if fi.IsDir() { | |
os.Stderr.WriteString("[ERROR] Cannot find voltageshift\n") | |
os.Exit(1) | |
} | |
} else { | |
os.Stderr.WriteString("[ERROR] Cannot find voltageshift\n") | |
os.Exit(1) | |
} | |
os.Chdir(selfdir) | |
argvs := []string{realfullrt} | |
if flag.NArg() > 0 { | |
argvs = append(argvs, flag.Args()...) | |
} | |
syscall.Exec(realfullrt, argvs, syscall.Environ()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment