"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/alias/expand/expand.go" between
gh-cli-1.11.0.tar.gz and gh-cli-1.12.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

expand.go  (gh-cli-1.11.0):expand.go  (gh-cli-1.12.0)
package expand package expand
import ( import (
"errors" "errors"
"fmt" "fmt"
"os" "os/exec"
"path/filepath"
"regexp" "regexp"
"runtime" "runtime"
"strings" "strings"
"github.com/cli/cli/internal/config" "github.com/cli/cli/internal/config"
"github.com/cli/safeexec" "github.com/cli/cli/pkg/findsh"
"github.com/google/shlex" "github.com/google/shlex"
) )
// ExpandAlias processes argv to see if it should be rewritten according to a us er's aliases. The // ExpandAlias processes argv to see if it should be rewritten according to a us er's aliases. The
// second return value indicates whether the alias should be executed in a new s hell process instead // second return value indicates whether the alias should be executed in a new s hell process instead
// of running gh itself. // of running gh itself.
func ExpandAlias(cfg config.Config, args []string, findShFunc func() (string, er ror)) (expanded []string, isShell bool, err error) { func ExpandAlias(cfg config.Config, args []string, findShFunc func() (string, er ror)) (expanded []string, isShell bool, err error) {
if len(args) < 2 { if len(args) < 2 {
// the command is lacking a subcommand // the command is lacking a subcommand
return return
skipping to change at line 83 skipping to change at line 82
newArgs, err = shlex.Split(expansion) newArgs, err = shlex.Split(expansion)
if err != nil { if err != nil {
return return
} }
expanded = append(newArgs, extraArgs...) expanded = append(newArgs, extraArgs...)
return return
} }
func findSh() (string, error) { func findSh() (string, error) {
shPath, err := safeexec.LookPath("sh") shPath, err := findsh.Find()
if err == nil { if err != nil {
return shPath, nil if errors.Is(err, exec.ErrNotFound) {
} if runtime.GOOS == "windows" {
return "", errors.New("unable to locate sh to exe
if runtime.GOOS == "windows" { cute the shell alias with. The sh.exe interpreter is typically distributed with
winNotFoundErr := errors.New("unable to locate sh to execute the Git for Windows.")
shell alias with. The sh.exe interpreter is typically distributed with Git for W }
indows.") return "", errors.New("unable to locate sh to execute she
// We can try and find a sh executable in a Git for Windows insta ll alias with")
ll
gitPath, err := safeexec.LookPath("git")
if err != nil {
return "", winNotFoundErr
}
shPath = filepath.Join(filepath.Dir(gitPath), "..", "bin", "sh.ex
e")
_, err = os.Stat(shPath)
if err != nil {
return "", winNotFoundErr
} }
return "", err
return shPath, nil
} }
return shPath, nil
return "", errors.New("unable to locate sh to execute shell alias with")
} }
 End of changes. 5 change blocks. 
28 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)